Skip to content

Publish ref blst-smoke-test #127

Publish ref blst-smoke-test

Publish ref blst-smoke-test #127

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
ref:
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.ref }}
- uses: regclient/actions/regctl-installer@4d6888fcc4842c9630f60ebc91715a45dd9bd7a3
- uses: proudust/gh-describe@70f72d4f6304ea053cf5a3d71c36211d5acc0c73
id: ghd
with:
commit-ish: ${{ inputs.ref || github.sha}}
- 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@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
- uses: sbt/setup-sbt@508b753e53cb6095967669e0911487d2b9bc9f41 # v1.1.22
- 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 != ''
env:
RAW_DOCKER_TAGS: ${{ inputs.raw-docker-tags }}
run: |
echo "TAGS=$RAW_DOCKER_TAGS" >> "$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/${{ steps.ghd.outputs.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 org.opencontainers.image.revision=${{ steps.ghd.outputs.sha }}
echo EOF
} >> "$GITHUB_OUTPUT"
id: annotations
- uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
if: inputs.environment != ''
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
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 }}
annotations: ${{ steps.annotations.outputs.annotations }}
- uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- 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"
- uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta-private
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
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=Waves Private Node
org.opencontainers.image.documentation=https://github.com/wavesplatform/Waves/blob/${{ github.sha }}/docker/README.md#waves-private-node
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@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
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 }}