Skip to content

Commit cea21fd

Browse files
committed
feat(ci): add deploy workflow
1 parent 4c86f56 commit cea21fd

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Deploy Explorer
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
12+
cancel-in-progress: true
13+
14+
env:
15+
NODE_OPTIONS: '--no-warnings'
16+
17+
jobs:
18+
deploy-preview:
19+
runs-on: ['ubuntu-latest']
20+
permissions:
21+
contents: read
22+
pull-requests: write
23+
env:
24+
npm_config_yes: true
25+
environment: 'explorer-preview'
26+
if: github.event_name == 'pull_request'
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
lfs: true
31+
- uses: nixbuild/nix-quick-install-action@v28
32+
- name: Fetch from Cache
33+
run: |
34+
nix develop
35+
nix build .#explorer
36+
- name: '[preview] 🔶 Publish to Cloudflare Pages'
37+
env:
38+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
39+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
40+
run: npx --yes wrangler@latest pages --project-name="explorer" deploy result >> /tmp/explorer_deploy.txt
41+
- name: Set Deploy Output
42+
run: |
43+
{
44+
echo 'DEPLOY_OUTPUT<<EOF'
45+
tail -n 2 /tmp/explorer_deploy.txt
46+
echo 'EOF'
47+
} >> $GITHUB_ENV
48+
- name: Comment Site Deploy Results
49+
uses: thollander/actions-comment-pull-request@v2
50+
with:
51+
message: |
52+
# Explorer 🔎
53+
${{ env.DEPLOY_OUTPUT }}
54+
55+
**${{ env.LAST_UPDATED_AT }}**
56+
comment_tag: deploy-explorer-preview-result
57+
58+
deploy-production:
59+
runs-on: 'ubuntu-latest'
60+
env:
61+
npm_config_yes: true
62+
environment: 'explorer-production'
63+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
lfs: true
68+
- uses: nixbuild/nix-quick-install-action@v28
69+
- name: Fetch from Cache
70+
run: |
71+
nix develop
72+
nix build .#explorer
73+
- name: '[production] 🔶 Publish to Cloudflare Pages'
74+
env:
75+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
76+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }}
77+
run: npx --yes wrangler@latest pages --project-name="explorer" --branch="main" deploy result

0 commit comments

Comments
 (0)