Skip to content

Commit 5235d1a

Browse files
Update deploy.yml
1 parent e3c4f93 commit 5235d1a

File tree

1 file changed

+32
-51
lines changed

1 file changed

+32
-51
lines changed

.github/workflows/deploy.yml

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,70 @@
1-
name: Deploy to GitHub Pages
1+
name: Registry Auto Deploy
22

33
on:
4-
push:
5-
branches: [main]
64
schedule:
7-
- cron: '0 * * * *'
5+
- cron: "*/15 * * * *"
86
workflow_dispatch:
97

108
permissions:
119
contents: write
1210
pages: write
1311
id-token: write
1412

15-
concurrency:
16-
group: "pages"
17-
cancel-in-progress: true
18-
1913
jobs:
20-
check-changes:
14+
update-submodule:
2115
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-
2616
steps:
27-
- name: Checkout repository
28-
uses: actions/checkout@v4
17+
- uses: actions/checkout@v4
2918
with:
3019
submodules: recursive
31-
fetch-depth: 0
3220

33-
- name: Detect changes
34-
id: check
21+
- name: Update registry submodule
3522
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
4233
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
5335

5436
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'
5739
runs-on: ubuntu-latest
58-
5940
steps:
60-
- name: Checkout repository
61-
uses: actions/checkout@v4
41+
- uses: actions/checkout@v4
6242
with:
6343
submodules: recursive
64-
fetch-depth: 0
6544

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
7450

75-
- name: Upload Artifact for Pages
51+
- name: Build project
52+
run: bun run build
53+
54+
- name: Upload Pages Artifact
7655
uses: actions/upload-pages-artifact@v3
7756
with:
7857
path: ./dist
79-
overwrite: true
58+
name: github-pages
59+
retention-days: 1
8060

8161
deploy:
8262
needs: build
8363
runs-on: ubuntu-latest
8464
environment:
8565
name: github-pages
86-
66+
url: ${{ steps.deployment.outputs.page_url }}
8767
steps:
8868
- name: Deploy to GitHub Pages
69+
id: deployment
8970
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)