Skip to content

Create and publish a Docker image on release #3

Create and publish a Docker image on release

Create and publish a Docker image on release #3

# loosley based on https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
#
# a push to "/refs/heads/releases/v1" results in a tag of "releases-v1" per https://github.com/docker/metadata-action#usage
name: Create and publish a Docker image on release
on:
push:
branches: ['release']
workflow_dispatch:
env:
REGISTRY: us-docker.pkg.dev/uwit-mci-iam/containers
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image-to-gar:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Auth to Cloud
uses: 'uwit-iam/action-auth-artifact-registry@main'
with:
credentials: "${{ secrets.MCI_GCLOUD_AUTH_JSON }}"
- name: Extract metadata (tags + labels) for Docker
id: meta
# should this be pinned?
# https://github.com/docker/metadata-action
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
# should this be pinned?
# https://github.com/docker/build-push-action
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.output.labels }}