Skip to content

Scheduled Redeploy

Scheduled Redeploy #63

Workflow file for this run

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