From d90005285e9dd84f713d1ea78abfbc2af75b6e83 Mon Sep 17 00:00:00 2001 From: Jon Richter Date: Thu, 19 Jan 2023 00:41:16 +0100 Subject: [PATCH] ci : add Docker Hub and GitHub Packages registries --- .github/workflows/build-and-push.yml | 37 ++++++++++++++++++---------- .github/workflows/dev.yml | 4 +-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index b5390bb..1143006 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,12 +1,8 @@ -name: Build and push image from ref +name: Build and push image on: workflow_call: inputs: - ref: - description: "A ref from this repository, CirclesUBI/pathfinder2" - required: true - type: string image: description: "The desired name of the image to build" default: 'pathfinder2' @@ -14,10 +10,6 @@ on: type: string workflow_dispatch: inputs: - ref: - description: "A ref from this repository, CirclesUBI/pathfinder2" - required: true - type: string image: description: "The desired name of the image to build" default: 'pathfinder2' @@ -32,14 +24,13 @@ jobs: permissions: contents: read id-token: write + packages: write steps: - name: Checkout repository uses: actions/checkout@v3 - with: - ref: ${{ inputs.ref }} - name: Set up Docker Buildx @@ -52,6 +43,8 @@ jobs: with: images: | ${{ vars.GC_REGISTRY }}/${{ vars.GC_PROJECT_ID }}/${{ inputs.image }} + docker.io/${{ vars.DH_ORGANIZATION }}/${{ inputs.image }} + ghcr.io/${{ github.repository_owner }}/${{ inputs.image }} labels: | org.opencontainers.image.title=${{ inputs.image }} org.opencontainers.image.vendor=CirclesUBI @@ -74,15 +67,33 @@ jobs: token_format: 'access_token' - - name: Login to Container Registry + name: Login to Google Cloud Container Registry uses: docker/login-action@v2 with: registry: ${{ vars.GC_REGISTRY }} username: 'oauth2accesstoken' password: '${{ steps.auth.outputs.access_token }}' - - name: Build and push Docker image + - + name: Login to Docker Hub Registry + uses: docker/login-action@v2 + with: + registry: docker.io + username: ${{ vars.DH_USERNAME }} + password: ${{ secrets.DH_TOKEN }} + + - + name: Login to GitHub Packages Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - + name: Build and push Container image uses: docker/build-push-action@v3 with: push: true tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 9d62173..d961675 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -10,8 +10,6 @@ jobs: permissions: contents: read id-token: write + packages: write uses: ./.github/workflows/build-and-push.yml - with: - ref: "${{ github.ref }}" - image: "pathfinder2" secrets: inherit