Skip to content

Commit

Permalink
build(docker): Publish image to Github Container Registry [DEV-2883] (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
filipdjokic authored Jun 29, 2023
2 parents 8b12c94 + d02f564 commit 1623789
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
name: "LogTo Docker image - Staging"
runs-on: ubuntu-latest
env:
IMAGE_NAME: registry.digitalocean.com/cheqd/creds-auth
IMAGE_NAME: cheqd/creds-auth

steps:
- uses: actions/checkout@v3
Expand All @@ -50,7 +50,10 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
images: |
${{ env.IMAGE_NAME }}
ghcr.io/${{ env.IMAGE_NAME }}
registry.digitalocean.com/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=raw,value=staging-latest
Expand All @@ -65,12 +68,10 @@ jobs:
load: true
target: runner
tags: ${{ steps.meta.outputs.tags }}
outputs: type=docker,dest=logto-staging.tar
cache-from: type=gha
cache-to: type=gha,mode=min

- name: Save Docker image
run: docker save ${{ env.IMAGE_NAME }} > logto-staging.tar

- name: Upload Docker test image
uses: actions/upload-artifact@v3
with:
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
needs: release-node
if: ${{ github.ref_name == 'main' }}
env:
IMAGE_NAME: registry.digitalocean.com/cheqd/creds-auth
IMAGE_NAME: cheqd/creds-auth
environment:
name: production
url: https://admin-auth.creds.xyz
Expand All @@ -78,12 +78,21 @@ jobs:

- name: Login to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600

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

- name: Configure Docker image metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE_NAME }}
images: |
ghcr.io/${{ env.IMAGE_NAME }}
registry.digitalocean.com/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
Expand All @@ -110,5 +119,9 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=min

- name: Push Logto image
run: docker image push --all-tags ${{ env.IMAGE_NAME }}
- name: Push image to GitHub Container Registry
run: docker image push --all-tags ghcr.io/${{ env.IMAGE_NAME }}

- name: Push image to DigitalOcean Container Registry
run: docker image push --all-tags registry.digitalocean.com/${{ env.IMAGE_NAME }}

14 changes: 12 additions & 2 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: "Staging Deploy"
runs-on: ubuntu-latest
env:
IMAGE_NAME: registry.digitalocean.com/cheqd/creds-auth
IMAGE_NAME: cheqd/creds-auth
environment:
name: staging
url: https://admin-auth-staging.creds.xyz
Expand All @@ -24,6 +24,13 @@ jobs:
- name: Login to DOCR
run: doctl registry login --expiry-seconds 600

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

- name: Download Docker image
uses: actions/download-artifact@v3
with:
Expand All @@ -32,5 +39,8 @@ jobs:
- name: Load Docker image
run: docker image load --input logto-staging.tar

- name: Push image to GitHub Container Registry
run: docker image push --all-tags ghcr.io/${{ env.IMAGE_NAME }}

- name: Push staging image to DOCR
run: docker image push --all-tags ${{ env.IMAGE_NAME }}
run: docker image push --all-tags registry.digitalocean.com/${{ env.IMAGE_NAME }}

0 comments on commit 1623789

Please sign in to comment.