|
1 | | -name: Deploy to GitHub Pages |
| 1 | +name: Registry Auto Deploy |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | 4 | schedule: |
7 | | - - cron: '0 * * * *' |
| 5 | + - cron: "*/15 * * * *" |
8 | 6 | workflow_dispatch: |
9 | 7 |
|
10 | 8 | permissions: |
11 | 9 | contents: write |
12 | 10 | pages: write |
13 | 11 | id-token: write |
14 | 12 |
|
15 | | -concurrency: |
16 | | - group: "pages" |
17 | | - cancel-in-progress: true |
18 | | - |
19 | 13 | jobs: |
20 | | - check-changes: |
| 14 | + update-submodule: |
21 | 15 | runs-on: ubuntu-latest |
22 | | - outputs: |
23 | | - should_deploy: ${{ steps.check.outputs.should_deploy }} |
24 | | - has_submodule_changes: ${{ steps.check.outputs.has_submodule_changes }} |
25 | | - |
26 | 16 | steps: |
27 | | - - name: Checkout repository |
28 | | - uses: actions/checkout@v4 |
| 17 | + - uses: actions/checkout@v4 |
29 | 18 | with: |
30 | 19 | submodules: recursive |
31 | | - fetch-depth: 0 |
32 | 20 |
|
33 | | - - name: Detect changes |
34 | | - id: check |
| 21 | + - name: Update registry submodule |
35 | 22 | run: | |
36 | | - echo "should_deploy=false" >> $GITHUB_OUTPUT |
37 | | - echo "has_submodule_changes=false" >> $GITHUB_OUTPUT |
38 | | - git submodule update --init --recursive --remote |
39 | | - if ! git diff --quiet; then |
40 | | - echo "has_submodule_changes=true" >> $GITHUB_OUTPUT |
41 | | - echo "should_deploy=true" >> $GITHUB_OUTPUT |
| 23 | + git submodule update --remote --merge sc/registry |
| 24 | + if [[ -n "$(git status --porcelain)" ]]; then |
| 25 | + git config user.name "github-actions[bot]" |
| 26 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 27 | + git add sc/registry |
| 28 | + git commit -m "Auto-update registry" |
| 29 | + git push |
| 30 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 31 | + else |
| 32 | + echo "changed=false" >> $GITHUB_OUTPUT |
42 | 33 | fi |
43 | | -
|
44 | | - - name: Commit submodule update |
45 | | - if: steps.check.outputs.has_submodule_changes == 'true' |
46 | | - run: | |
47 | | - git config user.name "github-actions[bot]" |
48 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
49 | | - git add -A |
50 | | - git commit -m "Update registry submodule" |
51 | | - git pull --rebase https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git main |
52 | | - git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git HEAD:main |
| 34 | + id: changecheck |
53 | 35 |
|
54 | 36 | build: |
55 | | - needs: check-changes |
56 | | - if: needs.check-changes.outputs.should_deploy == 'true' |
| 37 | + needs: update-submodule |
| 38 | + if: needs.update-submodule.outputs.changed == 'true' |
57 | 39 | runs-on: ubuntu-latest |
58 | | - |
59 | 40 | steps: |
60 | | - - name: Checkout repository |
61 | | - uses: actions/checkout@v4 |
| 41 | + - uses: actions/checkout@v4 |
62 | 42 | with: |
63 | 43 | submodules: recursive |
64 | | - fetch-depth: 0 |
65 | 44 |
|
66 | | - - name: Build Astro site |
67 | | - uses: withastro/action@v3 |
68 | | - with: |
69 | | - package-manager: bun@latest |
70 | | - env: |
71 | | - PUBLIC_SITE_NAME: Zig Index |
72 | | - PUBLIC_SITE_URL: https://zig-index.github.io |
73 | | - PUBLIC_REPO_URL: https://github.com/Zig-Index/zig-index.github.io |
| 45 | + - name: Setup Bun |
| 46 | + uses: oven-sh/setup-bun@v1 |
| 47 | + |
| 48 | + - name: Install dependencies |
| 49 | + run: bun install |
74 | 50 |
|
75 | | - - name: Upload Artifact for Pages |
| 51 | + - name: Build project |
| 52 | + run: bun run build |
| 53 | + |
| 54 | + - name: Upload Pages Artifact |
76 | 55 | uses: actions/upload-pages-artifact@v3 |
77 | 56 | with: |
78 | 57 | path: ./dist |
79 | | - overwrite: true |
| 58 | + name: github-pages |
| 59 | + retention-days: 1 |
80 | 60 |
|
81 | 61 | deploy: |
82 | 62 | needs: build |
83 | 63 | runs-on: ubuntu-latest |
84 | 64 | environment: |
85 | 65 | name: github-pages |
86 | | - |
| 66 | + url: ${{ steps.deployment.outputs.page_url }} |
87 | 67 | steps: |
88 | 68 | - name: Deploy to GitHub Pages |
| 69 | + id: deployment |
89 | 70 | uses: actions/deploy-pages@v4 |
0 commit comments