-
Notifications
You must be signed in to change notification settings - Fork 146
64 lines (57 loc) · 2.06 KB
/
publish-website.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
name: Publish website
on:
workflow_run:
workflows: ["Build website"]
types:
- completed
jobs:
publish:
runs-on: ubuntu-latest
env:
PR_INFO_FILE: ".PR_INFO"
steps:
- if: github.event.workflow_run.conclusion != 'success'
name: Abort if build failed
run: |
echo "build failed"
exit 1
# need to checkout to get "firebase.json", ".firebaserc"
- uses: actions/checkout@v4
- name: Download build artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: build-website.yml
run_id: ${{ github.event.workflow_run.id }}
name: website
path: website/build
- if: github.event.workflow_run.event == 'pull_request'
name: Download pr info
uses: dawidd6/action-download-artifact@v2
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: build-website.yml
run_id: ${{ github.event.workflow_run.id }}
name: pr-info
- if: github.event.workflow_run.event == 'pull_request'
name: Apply pull request environment
run: |
pr_number=$(cat "$PR_INFO_FILE")
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "pr number invalid"
exit 1
fi
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
echo "PR_BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV
echo "COMMIT_SHA=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_ENV
echo "CHANNEL_ID='$PR_NUMBER-$COMMIT_SHA'" >> $GITHUB_ENV
- if: github.event.workflow_run.event == 'push'
name: Apply push environment
run: |
echo "CHANNEL_ID=live" >> $GITHUB_ENV
- name: Deploy to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GLOO_RS }}'
channelId: "${{ env.CHANNEL_ID }}"