Skip to content

Commit 4ffff18

Browse files
authored
ci(app2): add workflow (#4061)
2 parents 4daaa0c + 0c2ce96 commit 4ffff18

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

.github/workflows/deploy-app2.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: Deploy App 2
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/app2
8+
paths:
9+
- 'app2/**'
10+
pull_request:
11+
paths:
12+
- 'app2/**'
13+
workflow_dispatch:
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
env:
20+
NODE_OPTIONS: '--no-warnings'
21+
ACTIONS_RUNNER_DEBUG: true
22+
23+
jobs:
24+
deploy-preview:
25+
runs-on: ['ubuntu-latest']
26+
permissions:
27+
contents: read
28+
pull-requests: write
29+
env:
30+
npm_config_yes: true
31+
ENVIRONMENT: 'preview'
32+
environment: 'app2-preview'
33+
if: github.event_name == 'pull_request'
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
lfs: true
38+
- uses: nixbuild/nix-quick-install-action@v28
39+
with:
40+
nix_conf: |
41+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= union.cachix.org-1:TV9o8jexzNVbM1VNBOq9fu8NK+hL6ZhOyOh0quATy+M=
42+
trusted-substituters = https://cache.nixos.org https://cache.garnix.io https://union.cachix.org
43+
- name: Fetch from Cache
44+
env:
45+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
46+
run: |
47+
nix build .#app2
48+
- name: '[preview] 🔶 Publish to Cloudflare Pages'
49+
env:
50+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
51+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
52+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
53+
run: npx --yes wrangler@latest pages --project-name="app2" deploy result >> /tmp/app2_deploy.txt
54+
55+
- name: Set Deploy Output
56+
run: |
57+
{
58+
echo 'DEPLOY_OUTPUT<<EOF'
59+
tail -n 2 /tmp/app2_deploy.txt
60+
echo 'EOF'
61+
} >> $GITHUB_ENV
62+
63+
- name: Comment Site Deploy Results
64+
uses: thollander/actions-comment-pull-request@v2
65+
with:
66+
message: |
67+
# App 2 🤌
68+
${{ env.DEPLOY_OUTPUT }}
69+
70+
**${{ env.LAST_UPDATED_AT }}**
71+
comment_tag: deploy-app2-preview-result
72+
73+
deploy-manual:
74+
runs-on: ['ubuntu-latest']
75+
env:
76+
npm_config_yes: true
77+
ENVIRONMENT: 'preview'
78+
if: github.event_name == 'workflow_dispatch'
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
lfs: true
83+
- uses: nixbuild/nix-quick-install-action@v28
84+
with:
85+
nix_conf: |
86+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= union.cachix.org-1:TV9o8jexzNVbM1VNBOq9fu8NK+hL6ZhOyOh0quATy+M=
87+
trusted-substituters = https://cache.nixos.org https://cache.garnix.io https://union.cachix.org
88+
- name: Fetch from Cache
89+
env:
90+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
91+
run: |
92+
nix build .#app2
93+
- name: '[workflow-dispatch] 🔶 Publish to Cloudflare Pages'
94+
env:
95+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
96+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
97+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
98+
run: npx --yes wrangler@latest pages --project-name="app2" deploy result
99+
100+
deploy-staging:
101+
runs-on: ['ubuntu-latest']
102+
env:
103+
npm_config_yes: true
104+
ENVIRONMENT: 'staging'
105+
environment: 'app2-staging'
106+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
107+
steps:
108+
- uses: actions/checkout@v4
109+
with:
110+
lfs: true
111+
- uses: nixbuild/nix-quick-install-action@v28
112+
with:
113+
nix_conf: |
114+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= union.cachix.org-1:TV9o8jexzNVbM1VNBOq9fu8NK+hL6ZhOyOh0quATy+M=
115+
trusted-substituters = https://cache.nixos.org https://cache.garnix.io https://union.cachix.org
116+
- name: Fetch from Cache
117+
env:
118+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
119+
run: |
120+
nix build .#app2
121+
- name: '[staging] 🔶 Publish to Cloudflare Pages'
122+
env:
123+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
124+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
125+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
126+
run: npx --yes wrangler@latest pages --project-name="app2" --branch="staging" deploy result
127+
128+
deploy-production:
129+
runs-on: ['ubuntu-latest']
130+
env:
131+
npm_config_yes: true
132+
ENVIRONMENT: 'production'
133+
environment: 'app2-production'
134+
if: github.event_name == 'push' && github.ref == 'refs/heads/release/app2'
135+
steps:
136+
- uses: actions/checkout@v4
137+
with:
138+
lfs: true
139+
- uses: nixbuild/nix-quick-install-action@v28
140+
with:
141+
nix_conf: |
142+
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g= union.cachix.org-1:TV9o8jexzNVbM1VNBOq9fu8NK+hL6ZhOyOh0quATy+M=
143+
trusted-substituters = https://cache.nixos.org https://cache.garnix.io https://union.cachix.org
144+
- name: Fetch from Cache
145+
env:
146+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
147+
run: |
148+
nix build .#app2
149+
- name: '[production] 🔶 Publish to Cloudflare Pages'
150+
env:
151+
ENVIRONMENT: ${{ env.ENVIRONMENT }}
152+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
153+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
154+
run: npx --yes wrangler@latest pages --project-name="app2" --branch="main" deploy result
155+

0 commit comments

Comments
 (0)