Create and publish a Docker image on release #4
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
# 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 | |
OWNER_IMAGE: ${{ 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: Compute repository name | |
id: image_name | |
run: | | |
# GH=uwit-iam/nginx-saml-proxy; echo ${GH#*/} returns "nginx-saml-proxy" | |
echo "IMAGE_NAME=${OWNER_IMAGE#*/}" >> $GITHUB_OUTPUT | |
- 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 }}/${{ steps.image_name.outputs.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 }} |