stagit/.github/workflows/mirror.yml (3291B)
name: mirror # The schedule is in cron/wrangler.jsonc: GitHub disables scheduled # workflows in public repos after 60 days without commits. on: push: branches: [main] workflow_dispatch: inputs: trigger: description: What started the run, for the deployment message type: choice options: [manual, scheduled] default: manual permissions: contents: read concurrency: group: deploy cancel-in-progress: false jobs: deploy: runs-on: ubuntu-latest env: SITE_URL: https://git.michaelneuper.com/ steps: - uses: actions/checkout@v7 - name: Install libgit2, md4c and pandoc run: | sudo apt-get update sudo apt-get install -y --no-install-recommends libgit2-dev libmd4c-dev libmd4c-html0-dev pandoc # Not packaged for Ubuntu; the checksum is from the release's # chroma-2.27.0-checksums.txt. - name: Install chroma run: | curl -fsSLO https://github.com/alecthomas/chroma/releases/download/v2.27.0/chroma-2.27.0-linux-amd64.tar.gz echo "91e1cd175006ff8a19cdd45ad12f9dd8c4eeeca4ec85703ebcc09cd31122f802 chroma-2.27.0-linux-amd64.tar.gz" | sha256sum -c - sudo tar xzf chroma-2.27.0-linux-amd64.tar.gz -C /usr/local/bin chroma - name: Build stagit run: make - name: Generate site run: ./build.sh env: GH_TOKEN: ${{ github.token }} GITHUB_USER: ${{ github.repository_owner }} SERVE_GIT: 1 # wrangler needs Node 22 or newer. - uses: actions/setup-node@v7 with: node-version: "22" # Reads wrangler.jsonc. The message, shown in the dashboard's # deployment list, is the commit's subject for a push. Other runs # name the repos whose refs differ from the live site's, or count # them when the list gets long. - name: Deploy to Cloudflare run: | if [ "$GITHUB_EVENT_NAME" = push ]; then message=$(git log -1 --format=%s) else changed= n=0 for refs in public/*.git/info/refs; do name=${refs#public/} name=${name%.git/info/refs} if ! curl -fs "$SITE_URL$name.git/info/refs" | cmp -s - "$refs"; then changed="$changed, $name" n=$((n + 1)) fi done changed=${changed#, } message="$TRIGGER mirror: ${changed:-no changes}" if [ ${#message} -gt 100 ]; then message="$TRIGGER mirror: $n repos changed" fi fi npx --yes wrangler@4.151.3 deploy --message "$message" env: TRIGGER: ${{ inputs.trigger }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} # Skipped on scheduled runs, which would only add identical versions. - name: Deploy the schedule if: inputs.trigger != 'scheduled' run: npx --yes wrangler@4.151.3 deploy -c cron/wrangler.jsonc --message "$(git log -1 --format=%s)" env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}