-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (65 loc) · 1.91 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: CD Workflow
on:
push:
tags:
- '*'
permissions:
contents: read
id-token: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/bake-action@v4
with:
files: docker-bake.hcl
load: 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/hoarder/api
deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Set up kubectl
uses: azure/setup-kubectl@v4
- name: Set up ID token
uses: actions/github-script@v7
id: id-token
with:
result-encoding: string
script: |
return await core.getIDToken('k8s.chitoku.jp');
- name: Set context
run: |
kubectl config set-cluster k8s.chitoku.jp --server=https://k8s.chitoku.jp
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
run: |
kubectl rollout restart deployment/hoarder-api