Files
2026-10-14 12:34:57 +02:00

77 lines
2.7 KiB
YAML

name: nightly
# Upstream sync -> regenerate -> validate -> version -> publish -> commit back.
# Stops successfully when mattpocock/skills has not moved. Credentials only from secrets.
on:
schedule:
- cron: "30 3 * * *"
workflow_dispatch:
jobs:
sync:
if: gitea.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm ci
- name: Sync upstream snapshot
id: sync
run: |
node scripts/sync-upstream.ts
if git diff --quiet -- upstream .opencode/state/upstream.json && git ls-files --error-unmatch upstream/UPSTREAM.json >/dev/null 2>&1 && [ -z "$(git status --porcelain -- upstream .opencode/state/upstream.json)" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Stop when nothing changed
if: steps.sync.outputs.changed == 'false'
run: echo "upstream unchanged; nothing to do"
- name: Regenerate OpenCode artifacts
if: steps.sync.outputs.changed == 'true'
run: node scripts/generate.ts
- name: Format, typecheck, test, build
if: steps.sync.outputs.changed == 'true'
run: |
npm run format
npm run check
npm test
npm run build
- name: Prepare changelog + version
if: steps.sync.outputs.changed == 'true'
run: node scripts/version.ts
- name: Commit generated changes back
if: steps.sync.outputs.changed == 'true'
run: |
SHA=$(node -p "require('./upstream/UPSTREAM.json').commit.slice(0,9)")
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions[bot]@noreply"
git remote set-url origin "https://x-access-token:${{ secrets.PACKAGE_TOKEN }}@${GITEA_HOST#https://}"
git add upstream skills agents manifest.json docs/skill-mapping.md CHANGELOG.md .opencode/state package-lock.json
if git diff --cached --quiet; then
echo "no generated changes to commit"
else
git commit -m "sync: update mattpocock skills to ${SHA} [skip ci]"
git push origin main
fi
env:
GITEA_HOST: ${{ gitea.server_url }}
- name: Publish to Gitea npm registry, tag, link
if: steps.sync.outputs.changed == 'true'
run: |
SHA=$(git rev-parse HEAD)
SERVER_URL="$SERVER_URL" REPOSITORY="$REPOSITORY" SHA="$SHA" TOKEN="$TOKEN" node scripts/release.ts
env:
SERVER_URL: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
TOKEN: ${{ secrets.PACKAGE_TOKEN }}