Skip to content

Publish Docker image #23

Publish Docker image

Publish Docker image #23

Workflow file for this run

name: Publish Docker image
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty to use package.json version)'
required: false
type: string
env:
REGISTRY_IMAGE: emrgntcmplxty/r2r-dashboard
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.version.outputs.RELEASE_VERSION }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Get version from package.json
id: package-version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Determine version to use
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "RELEASE_VERSION=${{ steps.package-version.outputs.VERSION }}" >> $GITHUB_OUTPUT
fi
- name: Set matrix
id: set-matrix
run: |
echo "matrix={\"include\":[{\"platform\":\"amd64\",\"runner\":\"amd3\"},{\"platform\":\"arm64\",\"runner\":\"arm3\"}]}" >> $GITHUB_OUTPUT
build:
needs: prepare
strategy:
fail-fast: false
matrix: ${{fromJson(needs.prepare.outputs.matrix)}}
runs-on: ${{ matrix.runner }}
permissions:
packages: write
contents: read
id-token: write
actions: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.platform }}
push: true
tags: ${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}-${{ matrix.platform }}
provenance: false
sbom: false
create-manifest:
needs: [prepare, build]
runs-on: ubuntu-latest
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Create and push manifest
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }} \
${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}-amd64 \
${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}-arm64
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest \
${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}-amd64 \
${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}-arm64
- name: Verify manifests
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ needs.prepare.outputs.release_version }}
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest