From 069a042238bae6fa14325cb14d0dd705ec352582 Mon Sep 17 00:00:00 2001 From: Alexander Falca <56982134+alexander-falca@users.noreply.github.com> Date: Thu, 15 Jul 2021 23:07:15 -0400 Subject: [PATCH] Create docker-image-push.yml --- .github/workflows/docker-image-push.yml | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/docker-image-push.yml diff --git a/.github/workflows/docker-image-push.yml b/.github/workflows/docker-image-push.yml new file mode 100644 index 0000000..c34c5cd --- /dev/null +++ b/.github/workflows/docker-image-push.yml @@ -0,0 +1,67 @@ +name: docker-image-push + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +on: + push: + tags: [ 'v*.*.*' ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: adobe/kratos + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.14 + + - name: Run Mage build + uses: magefile/mage-action@v1 + with: + version: latest + args: operator:build + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}