Build image and push to container registry #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build image and push to container registry | |
on: | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.repository.default_branch }} | |
fetch-depth: 50 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Prepare tags | |
id: tags | |
run: | | |
git fetch --all --tags | |
echo "DIGEST=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | |
echo "REF_NAME=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT | |
- name: Build image and push to container registry | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ format('ghcr.io/{0}:{1}', github.repository, steps.tags.outputs.DIGEST) }} | |
${{ format('ghcr.io/{0}:{1}', github.repository, steps.tags.outputs.REF_NAME) }} | |
${{ format('ghcr.io/{0}:{1}', github.repository, 'latest') }} |