projects

saturn

My website

feat: migrate to tangled

daniel daum committed parent ed8206d commit f083653Signed, not verified

SignedGitea couldn't verify the signature.

Showing 5 changed files with 120 additions and 85 deletions.

.gitea/workflows/deploy.yamldeleted +0 −42
@@ -1,42 +0,0 @@1name: Mirror and Deploy23on:4    push:5        branches:6            - main7    workflow_dispatch:89jobs:10    mirror:11        runs-on: ubuntu-latest12        steps:13            - name: Checkout14              uses: actions/checkout@v415              with:16                  fetch-depth: 01718            - name: Push to GitHub19              run: |20                  git remote add github https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/daniel-daum/saturn.git21                  git push github main --force22                  git push github --tags --force2324    deploy:25        runs-on: ubuntu-latest26        steps:27            - name: Checkout28              uses: actions/checkout@v42930            - name: Stage public files31              run: |32                  mkdir dist33                  git ls-files -z \34                      | grep -zv -e '^internal/' -e '^scripts/' -e '^workers/' -e '^\.gitea/' -e '^\.gitignore$' -e '^mise\.toml$' \35                      | xargs -0 cp --parents -t dist3637            - name: Deploy to Cloudflare Pages38              uses: cloudflare/wrangler-action@v339              with:40                  apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}41                  accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}42                  command: pages deploy dist --project-name=saturn --branch=main
.gitea/workflows/sync-posts.yamldeleted +0 −43
@@ -1,43 +0,0 @@1name: Sync23# run by hand (from the gitea app too): copies my bluesky posts and recent4# project commits into the html, publishes my writing to standard.site, and5# commits the result. the6# push is made with SYNC_TOKEN, a personal access token, because pushes made7# with the built-in actions token don't trigger other workflows, and Mirror8# and Deploy has to run after this.9on:10    workflow_dispatch:1112jobs:13    sync:14        runs-on: ubuntu-latest15        steps:16            - name: Checkout17              uses: actions/checkout@v418              with:19                  token: ${{ secrets.SYNC_TOKEN }}2021            - name: Sync posts22              run: |23                  node --version24                  node scripts/sync-posts.mjs2526            - name: Sync commits27              run: node scripts/sync-commits.mjs2829            - name: Publish to standard.site30              env:31                  ATPROTO_APP_PASSWORD: ${{ secrets.ATPROTO_APP_PASSWORD }}32              run: node scripts/sync-standard.mjs3334            - name: Commit and push35              run: |36                  if git diff --quiet; then37                      echo "nothing changed"38                      exit 039                  fi40                  git config user.name "${{ gitea.actor }}"41                  git config user.email "${{ gitea.actor }}@noreply.git.danieldaum.net"42                  git commit -am "chore: sync"43                  git push
.tangled/workflows/deploy.ymladded +32 −0
@@ -0,0 +1,32 @@1# deploys the site to cloudflare pages on every push to main. copies every2# tracked file except the ones that never go live (see the grep below).3# needs the CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets45when:6  - event: ["push", "manual"]7    branch: ["main"]89engine: "nixery"1011dependencies:12  nixpkgs:13    - gnugrep14    - findutils15    - wrangler1617environment:18  WRANGLER_SEND_METRICS: "false"1920steps:21  - name: "Stage public files"22    command: |23      set -euo pipefail24      mkdir dist25      git ls-files -z \26          | grep -zv -e '^internal/' -e '^scripts/' -e '^workers/' -e '^\.tangled/' -e '^\.gitignore$' -e '^mise\.toml$' \27          | xargs -0 cp --parents -t dist2829  - name: "Deploy to Cloudflare Pages"30    command: |31      set -euo pipefail32      wrangler pages deploy dist --project-name=saturn --branch=main
.tangled/workflows/mirror.ymladded +28 −0
@@ -0,0 +1,28 @@1# mirrors main to github and gitea on every push. tangled is the source of2# truth, so both get force-pushed to match it. needs the GH_MIRROR_TOKEN and3# GITEA_MIRROR_TOKEN secrets45when:6  - event: ["push", "manual"]7    branch: ["main"]89engine: "nixery"1011steps:12  # spindle clones one commit deep (depth: 0 means 1 too), and the mirrors13  # need the whole history. this also points origin/main at the newest main,14  # so a late or retried run never rolls the mirrors back15  - name: "Fetch full history"16    command: |17      set -euo pipefail18      git fetch --unshallow origin1920  - name: "Mirror to GitHub"21    command: |22      set -euo pipefail23      git push --force "https://x-access-token:${GH_MIRROR_TOKEN}@github.com/daniel-daum/saturn.git" refs/remotes/origin/main:refs/heads/main2425  - name: "Mirror to Gitea"26    command: |27      set -euo pipefail28      git push --force "https://daniel-daum:${GITEA_MIRROR_TOKEN}@git.danieldaum.net/daniel-daum/saturn.git" refs/remotes/origin/main:refs/heads/main
.tangled/workflows/sync.ymladded +60 −0
@@ -0,0 +1,60 @@1# copies my bluesky posts and recent project commits into the html,2# publishes my writing to standard.site, then commits and pushes the result3# back here, which runs deploy and mirror. runs once an hour. to run it now,4# open the latest sync pipeline and hit retry.5# needs the ATPROTO_APP_PASSWORD and TANGLED_PUSH_KEY secrets67when:8  - event: ["schedule"]9    schedule:10      - cron: "H * * * *"11  - event: ["manual"]1213engine: "nixery"1415dependencies:16  nixpkgs:17    - nodejs18    - openssh1920steps:21  # a scheduled run starts from whatever main was when spindle last looked,22  # so catch up before changing anything23  - name: "Check out the newest main"24    command: |25      set -euo pipefail26      git fetch origin main27      git checkout -B main FETCH_HEAD2829  - name: "Sync posts"30    command: node scripts/sync-posts.mjs3132  - name: "Sync commits"33    command: node scripts/sync-commits.mjs3435  - name: "Publish to standard.site"36    command: node scripts/sync-standard.mjs3738  - name: "Commit and push"39    command: |40      set -euo pipefail41      if git diff --quiet; then42          echo "nothing changed"43          exit 044      fi4546      # ssh refuses to run without a passwd entry, and nixery images have none47      mkdir -p /etc48      [ -e /etc/passwd ] || echo "root:x:0:0:root:${HOME}:/bin/bash" > /etc/passwd4950      mkdir -p "${HOME}/.ssh"51      printf '%s\n' "${TANGLED_PUSH_KEY}" > "${HOME}/.ssh/tangled"52      chmod 600 "${HOME}/.ssh/tangled"53      ssh-keyscan tangled.org > "${HOME}/.ssh/known_hosts"5455      git config user.name "daniel daum"56      git config user.email "daniel@danieldaum.net"57      git commit -am "chore: sync"5859      export GIT_SSH_COMMAND="ssh -i ${HOME}/.ssh/tangled -o IdentitiesOnly=yes -o UserKnownHostsFile=${HOME}/.ssh/known_hosts"60      git push git@tangled.org:danieldaum.net/saturn HEAD:refs/heads/main