|
1 | 1 | name: Deploy and Update Analytics |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
4 | 7 | schedule: |
5 | 8 | - cron: '0 0 * * *' # Runs every day at midnight UTC |
6 | 9 | workflow_dispatch: # Allows manual triggering |
7 | | - pull_request: |
8 | | - types: [closed] |
9 | | - branches: |
10 | | - - main |
11 | 10 |
|
12 | 11 | 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' |
15 | 57 | 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 |
17 | 60 | steps: |
18 | 61 | - uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + ref: 'main' |
| 64 | + fetch-depth: '0' |
19 | 65 |
|
20 | 66 | - name: Setup Node |
21 | 67 | uses: actions/setup-node@v4 |
22 | 68 | with: |
23 | 69 | node-version: '20.x' |
24 | 70 |
|
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 |
26 | 85 |
|
27 | 86 | - name: Run analytics update |
28 | 87 | run: npm run analytics |
|
0 commit comments