Skip to content

Commit

Permalink
ci : add Docker Hub and GitHub Packages registries
Browse files Browse the repository at this point in the history
  • Loading branch information
almereyda authored and chriseth committed Feb 25, 2023
1 parent cadee86 commit d900052
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
37 changes: 24 additions & 13 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
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'
required: false
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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
4 changes: 1 addition & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d900052

Please sign in to comment.