11name : Deploy and Update Analytics
22
33on :
4- push :
5- branches :
6- - main
74 schedule :
85 - cron : ' 0 0 * * *' # Runs every day at midnight UTC
96 workflow_dispatch : # Allows manual triggering
7+ pull_request :
8+ types : [closed]
9+ branches :
10+ - main
1011
1112jobs :
12- update-analytics :
13- if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
13+ update-analytics-and-deploy :
14+ if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.ref == 'refs/heads/main')
1415 runs-on : ubuntu-latest
1516 environment : github-pages # Specify the environment here
1617 steps :
@@ -31,46 +32,14 @@ jobs:
3132 GOOGLE_REFRESH_TOKEN : ${{ secrets.GOOGLE_REFRESH_TOKEN }}
3233 PROPERTY_ID : ${{ secrets.PROPERTY_ID }}
3334
34- deploy :
35- if : github.event_name == 'push'
36- runs-on : ubuntu-latest
37- environment : github-pages # Specify the environment here
38- steps :
39- - uses : actions/checkout@v4
40- with :
41- ref : ' main'
42- fetch-depth : ' 0'
43-
44- - name : Setup Node
45- uses : actions/setup-node@v2.1.2
46- with :
47- node-version : ' 20.x'
48-
49- - name : Reconfigure git to use HTTP authentication
50- run : >
51- git config --global url."https://github.com/".insteadOf
52- ssh://git@github.com/
53-
54- - name : Cache dependencies
55- uses : actions/cache@v3
56- with :
57- path : ~/.npm
58- key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
59- restore-keys : |
60- ${{ runner.os }}-node-
61-
62- - run : npm ci
63- - run : npm run build
64- env :
65- GOOGLE_CLIENT_ID : ${{ secrets.GOOGLE_CLIENT_ID }}
66- GOOGLE_CLIENT_SECRET : ${{ secrets.GOOGLE_CLIENT_SECRET }}
67- GOOGLE_REFRESH_TOKEN : ${{ secrets.GOOGLE_REFRESH_TOKEN }}
68- PROPERTY_ID : ${{ secrets.PROPERTY_ID }}
35+ - name : Build site
36+ run : npm run build
6937
70- - name : Deploy
38+ - name : Deploy to GitHub Pages
7139 uses : peaceiris/actions-gh-pages@v4
7240 with :
7341 github_token : ${{ secrets.GITHUB_TOKEN }}
7442 publish_dir : ./_site
7543 user_name : ' github-actions[bot]'
7644 user_email : ' github-actions[bot]@users.noreply.github.com'
45+ publish_branch : gh-pages
0 commit comments