Skip to content

Commit 80e5ba6

Browse files
committed
revert: separate update-analytics and deploy jobs to restore original workflow structure
- Reverted previous consolidation of `update-analytics` and `deploy` jobs back into separate jobs - Added `push` event trigger for the deploy job to ensure deployment runs automatically for every commit to `main` - Removed complex conditions for deployment on pull request merges in favor of simpler `push` trigger - Restored permissions setup (`contents: write`) to allow pushing to `gh-pages` branch - Switched back to explicit steps for each job, simplifying and clarifying workflow management
1 parent 6262371 commit 80e5ba6

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

.github/workflows/gh-pages.yml

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,87 @@
11
name: Deploy and Update Analytics
22

33
on:
4+
push:
5+
branches:
6+
- main
47
schedule:
58
- cron: '0 0 * * *' # Runs every day at midnight UTC
69
workflow_dispatch: # Allows manual triggering
7-
pull_request:
8-
types: [closed]
9-
branches:
10-
- main
1110

1211
jobs:
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')
12+
deploy:
13+
if: github.event_name == 'push'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # Ensure GitHub Actions can push to the repository
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: 'main'
21+
fetch-depth: '0'
22+
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20.x'
27+
28+
- name: Reconfigure git to use HTTP authentication
29+
run: >
30+
git config --global url."https://github.com/".insteadOf
31+
ssh://git@github.com/
32+
33+
- name: Cache dependencies
34+
uses: actions/cache@v3
35+
with:
36+
path: ~/.npm
37+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
38+
restore-keys: |
39+
${{ runner.os }}-node-
40+
41+
- run: npm ci
42+
43+
- name: Build site
44+
run: npm run build
45+
46+
- name: Deploy to GitHub Pages
47+
uses: peaceiris/actions-gh-pages@v4
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
publish_dir: ./_site
51+
user_name: 'github-actions[bot]'
52+
user_email: 'github-actions[bot]@users.noreply.github.com'
53+
publish_branch: gh-pages
54+
55+
update-analytics:
56+
if: github.event_name == 'schedule'
1557
runs-on: ubuntu-latest
16-
environment: github-pages # Specify the environment here
58+
permissions:
59+
contents: write # Ensure GitHub Actions can push to the repository
1760
steps:
1861
- uses: actions/checkout@v4
62+
with:
63+
ref: 'main'
64+
fetch-depth: '0'
1965

2066
- name: Setup Node
2167
uses: actions/setup-node@v4
2268
with:
2369
node-version: '20.x'
2470

25-
- run: npm install
71+
- name: Reconfigure git to use HTTP authentication
72+
run: >
73+
git config --global url."https://github.com/".insteadOf
74+
ssh://git@github.com/
75+
76+
- name: Cache dependencies
77+
uses: actions/cache@v3
78+
with:
79+
path: ~/.npm
80+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
81+
restore-keys: |
82+
${{ runner.os }}-node-
83+
84+
- run: npm ci
2685

2786
- name: Run analytics update
2887
run: npm run analytics

0 commit comments

Comments
 (0)