content-changed #791
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'root/**' | |
| - 'blog/**' | |
| - 'subgraphs/**' | |
| - 'scripts/**' | |
| - 'workspace.toml' | |
| - 'publish.toml' | |
| - '.github/workflows/publish.yml' | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [content-changed] | |
| concurrency: | |
| group: publish | |
| cancel-in-progress: true | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout cyber into ~/cyberia-to/cyber | |
| uses: actions/checkout@v4 | |
| with: | |
| path: cyber | |
| - name: Move into ~/cyberia-to/ | |
| run: | | |
| mkdir -p "$HOME/cyberia-to" | |
| mv cyber "$HOME/cyberia-to/cyber" | |
| - name: Clone declared subgraphs | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| ORG: cyberia-to | |
| run: | | |
| cd "$HOME/cyberia-to/cyber" | |
| for decl in subgraphs/*.md; do | |
| [ -f "$decl" ] || continue | |
| NAME=$(awk '/^name:/ {print $2; exit}' "$decl") | |
| REPO=$(awk '/^repo:/ {print $2; exit}' "$decl") | |
| ARCHIVED=$(awk '/^archived:/ {print $2; exit}' "$decl") | |
| ORPHAN=$(awk '/^orphan:/ {print $2; exit}' "$decl") | |
| VISIBILITY=$(awk '/^visibility:/ {print $2; exit}' "$decl") | |
| LOCAL_ONLY=$(awk '/^local-only:/ {print $2; exit}' "$decl") | |
| [ -z "$NAME" ] && continue | |
| [ -z "$REPO" ] && REPO="$NAME" | |
| [ "$ARCHIVED" = "true" ] && continue | |
| [ "$ORPHAN" = "true" ] && continue | |
| [ "$LOCAL_ONLY" = "true" ] && continue | |
| [ "$VISIBILITY" = "private" ] && continue | |
| [ "$REPO" = "cyber" ] && continue | |
| TARGET="$HOME/cyberia-to/$REPO" | |
| if [ ! -d "$TARGET" ]; then | |
| git clone --depth 1 "https://x-access-token:${GH_TOKEN}@github.com/${ORG}/${REPO}.git" "$TARGET" \ | |
| || echo "skip ${REPO}: clone failed" | |
| fi | |
| done | |
| - name: Install Nushell | |
| uses: hustcer/setup-nu@v3 | |
| with: | |
| version: '*' | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache optica build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| /tmp/optica-target-cache | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-optica-v3 | |
| restore-keys: | | |
| ${{ runner.os }}-optica- | |
| - name: Build optica | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| rm -rf "$HOME/cyberia-to/optica" | |
| git clone --depth 1 "https://x-access-token:${GH_TOKEN}@github.com/cyberia-to/optica.git" "$HOME/cyberia-to/optica" | |
| if [ -d /tmp/optica-target-cache ]; then | |
| mv /tmp/optica-target-cache "$HOME/cyberia-to/optica/target" | |
| fi | |
| cd "$HOME/cyberia-to/optica" && cargo build --release | |
| cp -r "$HOME/cyberia-to/optica/target" /tmp/optica-target-cache | |
| - name: Build site | |
| run: | | |
| cd "$HOME/cyberia-to/cyber" | |
| nu scripts/build.nu --public-only \ | |
| --optica "$HOME/cyberia-to/optica/target/release/optica" \ | |
| --output "$HOME/cyberia-to/cyber/build" | |
| - name: Add deploy files | |
| run: touch "$HOME/cyberia-to/cyber/build/.nojekyll" | |
| - name: Deploy to Netlify | |
| env: | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
| NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
| run: | | |
| npm install -g netlify-cli | |
| netlify deploy --prod \ | |
| --dir="$HOME/cyberia-to/cyber/build" \ | |
| --site="$NETLIFY_SITE_ID" \ | |
| --auth="$NETLIFY_AUTH_TOKEN" |