-
Notifications
You must be signed in to change notification settings - Fork 37
156 lines (148 loc) · 6.22 KB
/
custom-build.yaml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Custom Build
on:
push:
branches:
- '*'
- '!gh-pages'
tags:
- '*'
# We need to set id-token to write.
# But we cannot simply write
# permissions:
# id-token: write
# because those unspecified permissions are 'none', instead of taking their default values, as documented in
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
# So we repeat the defaults here.
permissions:
# The following are the default values we have to repeat here.
actions: "write"
attestations: "write"
checks: "write"
contents: "write"
deployments: "write"
discussions: "write"
issues: "write"
packages: "write"
pages: "write"
pull-requests: "write"
repository-projects: "write"
security-events: "write"
statuses: "write"
# The above are the default values we have to repeat here.
# We need to set id-token: write so that we can fetch the ID token.
# See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
# The ID token is used in Workload Identity Federation.
id-token: "write"
jobs:
authgear-image-custom:
runs-on: ubuntu-24.04
if: ${{ github.repository == 'authgear/authgear-server' }}
steps:
- uses: actions/checkout@v4
# https://aran.dev/posts/github-actions-go-private-modules/
- name: Set up SSH key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
AUTHGEAR_PRIVATE_DEPLOY_KEY: ${{ secrets.AUTHGEAR_PRIVATE_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh
eval $(ssh-agent -a $SSH_AUTH_SOCK)
printf "$AUTHGEAR_PRIVATE_DEPLOY_KEY" | base64 --decode | ssh-add -
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> "$GITHUB_ENV"
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> "$GITHUB_ENV"
- run: make -C custombuild build-image TARGET=authgearx IMAGE_NAME=authgear-server-custom
- name: Clean up SSH key
if: ${{ always() }}
run: |
ssh-add -D
ssh-agent -k
echo "SSH_AUTH_SOCK=" >> "$GITHUB_ENV"
echo "SSH_AGENT_PID=" >> "$GITHUB_ENV"
- uses: oursky/google-github-actions-auth@v2
with:
project_id: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_PROJECT_ID_HK }}
workload_identity_provider: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_WORKLOAD_IDENTITY_PROVIDER_HK }}
- uses: oursky/google-github-actions-setup-gcloud@v2
- name: Configure docker
env:
REPO: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_HK }}
run: |
gcloud auth configure-docker "$REPO"
- name: Push to HK
env:
REPO_PREFIX: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_PREFIX_HK }}
run: |
make -C custombuild tag-image IMAGE_NAME=authgear-server-custom REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-server"
make -C custombuild push-image REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-server" || docker logout "$REPO"
- uses: oursky/google-github-actions-auth@v2
with:
project_id: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_PROJECT_ID_US }}
workload_identity_provider: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_WORKLOAD_IDENTITY_PROVIDER_US }}
- uses: oursky/google-github-actions-setup-gcloud@v2
- name: Configure docker
env:
REPO: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_US }}
run: |
gcloud auth configure-docker "$REPO"
- name: Push to US
env:
REPO_PREFIX: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_PREFIX_US }}
run: |
make -C custombuild tag-image IMAGE_NAME=authgear-server-custom REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-server"
make -C custombuild push-image REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-server" || docker logout "$REPO"
portal-image-custom:
runs-on: ubuntu-24.04
if: ${{ github.repository == 'authgear/authgear-server' }}
steps:
- uses: actions/checkout@v4
# https://aran.dev/posts/github-actions-go-private-modules/
- name: Set up SSH key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
AUTHGEAR_PRIVATE_DEPLOY_KEY: ${{ secrets.AUTHGEAR_PRIVATE_DEPLOY_KEY }}
run: |
mkdir -p ~/.ssh
eval $(ssh-agent -a $SSH_AUTH_SOCK)
printf "$AUTHGEAR_PRIVATE_DEPLOY_KEY" | base64 --decode | ssh-add -
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> "$GITHUB_ENV"
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> "$GITHUB_ENV"
- run: make -C custombuild build-image TARGET=portalx IMAGE_NAME=authgear-portal-custom
- name: Clean up SSH key
if: ${{ always() }}
run: |
ssh-add -D
ssh-agent -k
echo "SSH_AUTH_SOCK=" >> "$GITHUB_ENV"
echo "SSH_AGENT_PID=" >> "$GITHUB_ENV"
- uses: oursky/google-github-actions-auth@v2
with:
project_id: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_PROJECT_ID_HK }}
workload_identity_provider: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_WORKLOAD_IDENTITY_PROVIDER_HK }}
- uses: oursky/google-github-actions-setup-gcloud@v2
- name: Configure docker
env:
REPO: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_HK }}
run: |
gcloud auth configure-docker "$REPO"
- name: Push to HK
env:
REPO_PREFIX: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_PREFIX_HK }}
run: |
make -C custombuild tag-image IMAGE_NAME=authgear-portal-custom REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-portal"
make -C custombuild push-image REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-portal" || docker logout "$REPO"
- uses: oursky/google-github-actions-auth@v2
with:
project_id: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_PROJECT_ID_US }}
workload_identity_provider: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_GOOGLE_WORKLOAD_IDENTITY_PROVIDER_US }}
- uses: oursky/google-github-actions-setup-gcloud@v2
- name: Configure docker
env:
REPO: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_US }}
run: |
gcloud auth configure-docker "$REPO"
- name: Push to US
env:
REPO_PREFIX: ${{ secrets.AUTHGEAR_CUSTOM_BUILD_REPO_PREFIX_US }}
run: |
make -C custombuild tag-image IMAGE_NAME=authgear-portal-custom REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-portal"
make -C custombuild push-image REMOTE_IMAGE_NAME="$REPO_PREFIX/authgear-portal" || docker logout "$REPO"