Skip to content

Build and Publish Docker Image #3

Build and Publish Docker Image

Build and Publish Docker Image #3

Workflow file for this run

name: Build and Publish Docker Image
on:
workflow_run:
workflows: ["Test"]
types:
- completed
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version and commit hash
id: version
run: |
echo "VERSION=$(jq -r .version < package.json)-${{ github.sha }}" >> $GITHUB_ENV
echo "SHORT_SHA=${{ github.sha }}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest,
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }},
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }}-$(echo ${{ env.SHORT_SHA }} | head -c 8)