Build-&-Push-Docker-Image #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
on: | |
push: | |
tags: [ 'v*.*.*' ] | |
workflow_dispatch: | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
# This is used to complete the identity challenge | |
# with sigstore/fulcio when running outside of PRs. | |
id-token: write | |
steps: | |
- name: Checkout latest release from repo | |
uses: actions/checkout@v4 | |
- name: get last tag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
id: get-latest-tag | |
- name: Show value of 'get last tag' | |
run: echo ${{ steps.get-latest-tag.outputs.tag }} | |
- name: Login to ${{ env.REGISTRY }} | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
# minimal | |
type=semver,pattern={{version}} | |
# use custom value instead of git tag | |
type=semver,pattern={{version}},value=${{ steps.get-latest-tag.outputs.tag }} | |
- name: Show value of 'docker meta data' | |
run: echo ${{ steps.meta.outputs }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
context: . | |
file: Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} # Don't push on PR | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |