Skip to content

Publish ref p256-verification #105

Publish ref p256-verification

Publish ref p256-verification #105

name: Publish Docker image
run-name: Publish ref ${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
docker-tags:
description: 'Docker tags'
required: true
base-image:
description: 'Base image'
required: false
publish-private-node:
description: 'Publish private node'
type: boolean
default: false
workflow_call:
inputs:
raw-docker-tags:
type: string
environment:
type: string
secrets:
DOCKERHUB_USER:
required: true
DOCKERHUB_PASSWORD:
required: true
outputs:
digest:
value: ${{ jobs.publish.outputs.digest }}
env:
IMAGE_NAME: ghcr.io/wavesplatform/waves
jobs:
publish:
name: Publish Docker image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
attestations: write
id-token: write
outputs:
digest: ${{ steps.push.outputs.digest }}
node-version: ${{ steps.versions.outputs.node-version }}
steps:
- uses: actions/checkout@v4
- uses: regclient/actions/regctl-installer@4d6888fcc4842c9630f60ebc91715a45dd9bd7a3
- uses: proudust/gh-describe@70f72d4f6304ea053cf5a3d71c36211d5acc0c73
id: ghd
- name: Prepare base image and node version
run: |
BASE_IMAGE=${{ inputs.base-image }}
BASE_IMAGE=${BASE_IMAGE:-$(head -n1 docker/Dockerfile | cut -d= -f2-)}
echo "base-image=$BASE_IMAGE" >> "$GITHUB_OUTPUT"
echo "base-image-digest=$(regctl manifest digest $BASE_IMAGE)" >> "$GITHUB_OUTPUT"
echo "node-version=$(echo ${{ steps.ghd.outputs.describe }} | cut -c 2-)" >> "$GITHUB_OUTPUT"
id: versions
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Build tarballs for docker
run: sbt --batch -Dproject.version=${{ steps.versions.outputs.node-version }} buildTarballsForDocker
- name: Extract image name and tags from workflow_call inputs
if: inputs.raw-docker-tags != ''
run: |
{
echo 'TAGS<<EOF'
echo ${{ inputs.raw-docker-tags }}
echo EOF
} >> "$GITHUB_ENV"
{
echo 'IMAGES<<EOF'
echo ${{ env.IMAGE_NAME }}
echo wavesplatform/wavesnode
echo EOF
} >> "$GITHUB_ENV"
- name: Extract image name and tags from workflow_dispatch inputs
if: github.event_name == 'workflow_dispatch'
run: |
{
echo 'TAGS<<EOF'
echo ${{ inputs.docker-tags }} | tr ',' '\n' | sed -e 's/^/type=raw,value=/'
echo EOF
} >> "$GITHUB_ENV"
echo "IMAGES=${{ env.IMAGE_NAME }}" >> "$GITHUB_ENV"
- name: Prepare annotations
run: |
{
echo 'annotations<<EOF'
echo org.opencontainers.image.source=https://github.com/${{ github.repository }}/tree/${{ github.sha }}/docker
echo org.opencontainers.image.licenses=MIT
echo org.opencontainers.image.description=Waves Node
echo org.opencontainers.image.base.name=${{ steps.versions.outputs.base-image }}
echo org.opencontainers.image.base.digest=${{ steps.versions.outputs.base-image-digest }}
echo org.opencontainers.image.version=${{ steps.versions.outputs.node-version }}
echo EOF
} >> "$GITHUB_OUTPUT"
id: annotations
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
if: inputs.environment != ''
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index,manifest-descriptor,index-descriptor
with:
images: ${{ env.IMAGES }}
flavor: latest=${{ contains(inputs.docker-tags, 'latest') }}
tags: ${{ env.TAGS }}
labels: ${{ steps.tag-list.outputs.annotations }}
annotations: ${{ steps.annotations.outputs.annotations }}
- uses: docker/build-push-action@v6
id: push
with:
context: ./docker
platforms: linux/amd64,linux/arm64
push: true
build-args: baseImage=${{ steps.versions.outputs.base-image }}@${{ steps.versions.outputs.base-image-digest }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prepare summary
run: |
{
echo '## Image Info'
echo '- This image: `${{ env.IMAGE_NAME }}@${{ steps.push.outputs.digest }}`'
echo '- Base image: `${{ steps.versions.outputs.base-image }}@${{ steps.versions.outputs.base-image-digest }}`'
echo '- Version: `${{ steps.versions.outputs.node-version }}`'
} >> $GITHUB_STEP_SUMMARY
publish-private-node:
needs: [publish]
name: Publish private node image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
if: ${{ inputs.publish-private-node }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- run: |
{
echo 'description<<EOF'
cat docker/private/README.md
echo EOF
} >> "$GITHUB_OUTPUT"
id: description
- run: |
{
echo 'TAGS<<EOF'
echo ${{ inputs.docker-tags }} | tr ',' '\n' | sed -e 's/^/type=raw,value=/'
echo EOF
} >> "$GITHUB_ENV"
- id: meta-private
uses: docker/metadata-action@v5
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index,manifest-descriptor,index-descriptor
with:
images: ghcr.io/wavesplatform/waves-private-node
flavor: latest=false
tags: ${{ env.TAGS }}
annotations: |
org.opencontainers.image.description=${{ steps.description.outputs.description }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ needs.publish.outputs.node-version }}
org.opencontainers.image.base.digest=${{ needs.publish.outputs.digest }}
- uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: ./docker/private
push: true
pull: true
tags: ${{ steps.meta-private.outputs.tags }}
build-args: |
baseImage=ghcr.io/wavesplatform/waves@${{ needs.publish.outputs.digest }}