Skip to content

Commit

Permalink
Publish images to ghcr.io
Browse files Browse the repository at this point in the history
  • Loading branch information
chitoku-k committed Aug 25, 2024
1 parent ef63032 commit 337cd4f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
36 changes: 15 additions & 21 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defaults:

permissions:
contents: read
packages: write
id-token: write

jobs:
Expand All @@ -26,31 +27,22 @@ jobs:
gpg --quiet --batch --yes --decrypt --passphrase=${{ secrets.FONTS_PASSPHRASE }} --output client/fonts.tar.gz client/fonts.tar.gz.gpg
cd client/fonts
tar xf ../fonts.tar.gz
- name: Build
- name: Log into Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/bake-action@v5
env:
TAG: ${{ github.ref_name }}
with:
files: docker-bake.hcl
load: true
push: true
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: Set up ID token
uses: actions/github-script@v7
id: id-token
with:
result-encoding: string
script: |
return await core.getIDToken('container.chitoku.jp');
- name: Log into Container Registry
uses: docker/login-action@v3
with:
registry: container.chitoku.jp
username: oidc-idtoken
password: ${{ steps.id-token.outputs.result }}
- name: Push to Container Registry
run: |
docker push container.chitoku.jp/chitoku-k/homochecker/api
docker push container.chitoku.jp/chitoku-k/homochecker/web
deploy:
name: Deploy
runs-on: ubuntu-latest
Expand All @@ -72,6 +64,8 @@ jobs:
kubectl config set-credentials github-actions --token=${{ steps.id-token.outputs.result }}
kubectl config set-context k8s.chitoku.jp --cluster=k8s.chitoku.jp --user=github-actions
kubectl config use-context k8s.chitoku.jp
- name: Rollout restart
- name: Update images
run: |
kubectl rollout restart deployment/homochecker-app
kubectl set image deployment/homochecker-app \
api=ghcr.io/chitoku-k/homochecker/api:${{ github.ref_name }} \
web=ghcr.io/chitoku-k/homochecker/web:${{ github.ref_name }}
14 changes: 12 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
variable "TAG" {
default = "latest"
}

group "default" {
targets = ["api", "web"]
}

target "api" {
context = "./api"
tags = ["container.chitoku.jp/chitoku-k/homochecker/api"]
tags = [
"ghcr.io/chitoku-k/homochecker/api:latest",
"ghcr.io/chitoku-k/homochecker/api:${TAG}",
]
}

target "web" {
context = "."
tags = ["container.chitoku.jp/chitoku-k/homochecker/web"]
tags = [
"ghcr.io/chitoku-k/homochecker/web:latest",
"ghcr.io/chitoku-k/homochecker/web:${TAG}",
]
}

0 comments on commit 337cd4f

Please sign in to comment.