Skip to content

Commit

Permalink
Merge pull request #1365 from alphagov/push-to-ghcr
Browse files Browse the repository at this point in the history
Push to images to ghcr.io
  • Loading branch information
theseanything authored Jul 8, 2024
2 parents 11d6dc9 + 7e67fe0 commit 2746e3a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -51,6 +52,13 @@ jobs:
with:
mask-password: 'true'

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -63,6 +71,7 @@ jobs:
with:
images: |
${{ steps.login-ecr.outputs.registry }}/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/${{ inputs.ecrRepositoryName }}
tags: |
type=raw,priority=500,value=${{ inputs.gitRef }},enable=${{ startsWith(inputs.gitRef, 'v') }}
type=raw,priority=400,value=${{ steps.local-head.outputs.sha }},enable=${{ !startsWith(inputs.gitRef, 'v') }}
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/build-and-push-multiarch-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -62,6 +63,13 @@ jobs:
with:
mask-password: 'true'

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/setup-buildx-action@v3

- run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
Expand All @@ -73,6 +81,7 @@ jobs:
with:
images: |
${{ steps.login-ecr.outputs.registry }}/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/${{ inputs.ecrRepositoryName }}
labels: |
org.opencontainers.image.vendor=GDS
tags: |
Expand Down Expand Up @@ -117,6 +126,7 @@ jobs:
permissions:
id-token: write
contents: read
packages: write
steps:
- name: Download Digests
uses: actions/download-artifact@v4
Expand All @@ -143,12 +153,20 @@ jobs:
with:
mask-password: 'true'

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ steps.login-ecr.outputs.registry }}/${{ inputs.ecrRepositoryName }}
ghcr.io/${{ github.repository_owner }}/${{ inputs.ecrRepositoryName }}
labels: |
org.opencontainers.image.vendor=GDS
tags: |
Expand Down

0 comments on commit 2746e3a

Please sign in to comment.