From c0e6e239c863af81ad6a705bbca717836e7cf957 Mon Sep 17 00:00:00 2001 From: Alex Lovell-Troy Date: Wed, 17 Apr 2024 16:03:18 -0400 Subject: [PATCH] Update build_containers.yml Extend the usage of the docker actions to support tagging using the version tagging on the repo --- .github/workflows/build_containers.yml | 31 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_containers.yml b/.github/workflows/build_containers.yml index dcff58c..1467761 100644 --- a/.github/workflows/build_containers.yml +++ b/.github/workflows/build_containers.yml @@ -1,5 +1,8 @@ name: build and publish containers -on: workflow_dispatch +on: + push: + tags: + - v* permissions: packages: write contents: read @@ -9,6 +12,23 @@ jobs: steps: - name: check out the repo uses: actions/checkout@v4 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + openchami/local-ca + ghcr.io/openchami/local-ca + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: setup Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to github container repo @@ -17,9 +37,10 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: build+push + - name: Build and push uses: docker/build-push-action@v5 with: - context: "{{defaultContext}}:local-ca" - push: true - tags: ghcr.io/openchami/local-ca:acme + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}