-
Notifications
You must be signed in to change notification settings - Fork 84
65 lines (61 loc) · 2.52 KB
/
Copy pathsite-refresh.yml
File metadata and controls
65 lines (61 loc) · 2.52 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
name: Website daily refresh
# Cloudflare Workers Builds redeploys on every push to main, so the star count on both
# sites is only as fresh as the last push. This rebuilds and deploys once a day, and
# skips when a push or an earlier refresh already deployed within the last 24 hours.
on:
schedule:
- cron: "17 6 * * *"
workflow_dispatch:
inputs:
force:
description: Deploy even if something already shipped in the last 24 hours
type: boolean
default: false
permissions:
contents: read
actions: read
jobs:
refresh:
name: Rebuild and deploy
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ github.token }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
steps:
- uses: actions/checkout@v4
- name: Check whether a deploy is due
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
pushed=$(git log -1 --format=%ct)
refreshed=$(gh run list --workflow site-refresh.yml --status success --limit 1 --json updatedAt --jq '.[0].updatedAt // empty')
[ -n "$refreshed" ] && refreshed=$(date -d "$refreshed" +%s) || refreshed=0
newest=$(( pushed > refreshed ? pushed : refreshed ))
age=$(( $(date +%s) - newest ))
echo "Last deploy was $(( age / 3600 ))h ago"
echo "due=$([ $age -ge 86400 ] || [ "${{ inputs.force }}" = "true" ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
[ -n "$CLOUDFLARE_API_TOKEN" ] || echo "::warning::CLOUDFLARE_API_TOKEN is unset, nothing will deploy"
- uses: actions/setup-node@v4
if: steps.check.outputs.due == 'true' && env.CLOUDFLARE_API_TOKEN != ''
with:
node-version: 22
cache: npm
cache-dependency-path: site/package-lock.json
- run: npm ci --prefix site
if: steps.check.outputs.due == 'true' && env.CLOUDFLARE_API_TOKEN != ''
- name: Deploy claudesettings.com
if: steps.check.outputs.due == 'true' && env.CLOUDFLARE_API_TOKEN != ''
env:
SITE_VARIANT: settings
run: |
npm run build --prefix site
npx --yes wrangler deploy --config wrangler.claudesettings.jsonc
- name: Deploy agentplugins.net
if: steps.check.outputs.due == 'true' && env.CLOUDFLARE_API_TOKEN != ''
env:
SITE_VARIANT: plugins
run: |
npm run build --prefix site
npx --yes wrangler deploy --config wrangler.agentplugins.jsonc