Repository navigation
80 lines (73 loc) · 2.35 KB
/
Copy pathredeploy.yml
File metadata and controls
80 lines (73 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Scheduled Redeploy
on:
schedule:
- cron: '*/10 * * * *' # Every 10 minutes
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# Redeployment when repositories.txt changed recently. The build is cached
# (actions/cache on .next/cache) to hit the <6 minute target.
jobs:
check:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check-changes.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for repositories.txt changes
id: check-changes
run: |
LAST_COMMIT=$(git log -1 --format=%ct -- repositories.txt || echo 0)
CURRENT_TIME=$(date +%s)
TIME_DIFF=$((CURRENT_TIME - LAST_COMMIT))
echo "Last commit: $LAST_COMMIT"
echo "Current time: $CURRENT_TIME"
echo "Time difference: $TIME_DIFF seconds"
# Only deploy if changed in the last 15 minutes
if [ "$TIME_DIFF" -lt 900 ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "repositories.txt has recent changes, deploying"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No recent changes, skipping deployment"
fi
build:
needs: check
if: needs.check.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache .next build cache
uses: actions/cache@v4
with:
path: .next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-${{ github.run_id }}
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-
- run: bun install
- name: Build static export
run: bun run build
env:
NEXT_PUBLIC_HOSTING_ENVIRONMENT: github
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'out'
deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5