content-changed #885
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: | |
| - '**.md' | |
| - 'blog/**' | |
| - 'subgraphs.toml' | |
| - '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: Clone cyber into ~/cyber/cyber | |
| run: | | |
| mkdir -p "$HOME/cyber" | |
| git clone --depth 1 https://github.com/cyberia-to/cyber.git "$HOME/cyber/cyber" | |
| - name: Install Nushell | |
| run: | | |
| NU_TAG=$(curl -fsSL https://api.github.com/repos/nushell/nushell/releases/latest | grep '"tag_name"' | cut -d'"' -f4) | |
| NU_VER="${NU_TAG#v}" | |
| ARCHIVE="nu-${NU_VER}-x86_64-unknown-linux-gnu.tar.gz" | |
| curl -fsSL "https://github.com/nushell/nushell/releases/download/${NU_TAG}/${ARCHIVE}" -o /tmp/nu.tar.gz | |
| tar -xzf /tmp/nu.tar.gz -C /tmp | |
| sudo cp "/tmp/nu-${NU_VER}-x86_64-unknown-linux-gnu/nu" /usr/local/bin/nu | |
| nu --version | |
| - name: Clone public subgraphs from subgraphs.toml | |
| run: | | |
| cd "$HOME/cyber/cyber" | |
| nu -c ' | |
| let decls = (open subgraphs.toml | get subgraph) | |
| $decls | |
| | where {|d| ($d.name? | default "") != "cyber"} | |
| | where {|d| ($d.archived? | default false) != true} | |
| | where {|d| ($d.orphan? | default false) != true} | |
| | where {|d| ($d."local-only"? | default false) != true} | |
| | where {|d| ($d.visibility? | default "public") == "public"} | |
| | each {|d| | |
| let name = $d.name | |
| let target = $"($env.HOME)/cyber/($name)" | |
| if not ($target | path exists) { | |
| print $"Cloning ($name)..." | |
| let url = $"https://github.com/cyberia-to/($name).git" | |
| try { | |
| ^git clone --depth 1 $url $target | |
| } catch {|e| | |
| print $"skip ($name): ($e.msg)" | |
| } | |
| } | |
| } | |
| ' | |
| - name: Install Rust | |
| run: | | |
| rustup update stable | |
| rustup default stable | |
| - name: Cache optica build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| /tmp/optica-target-cache | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| key: ${{ runner.os }}-optica-v4 | |
| - name: Build optica | |
| run: | | |
| rm -rf "$HOME/cyber/optica" | |
| git clone --depth 1 https://github.com/cyberia-to/optica.git "$HOME/cyber/optica" | |
| if [ -d /tmp/optica-target-cache ]; then | |
| mv /tmp/optica-target-cache "$HOME/cyber/optica/target" | |
| fi | |
| cd "$HOME/cyber/optica" && cargo build --release | |
| cp -r "$HOME/cyber/optica/target" /tmp/optica-target-cache | |
| - name: Build site | |
| run: | | |
| cd "$HOME/cyber/cyber" | |
| nu scripts/build.nu --public-only \ | |
| --optica "$HOME/cyber/optica/target/release/optica" \ | |
| --output "$HOME/cyber/cyber/build" | |
| - name: Add deploy files | |
| run: touch "$HOME/cyber/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/cyber/cyber/build" \ | |
| --site="$NETLIFY_SITE_ID" \ | |
| --auth="$NETLIFY_AUTH_TOKEN" | |
| - name: Trigger .github rebuild | |
| continue-on-error: true | |
| env: | |
| CYBER_DISPATCH_TOKEN: ${{ secrets.CYBER_DISPATCH_TOKEN }} | |
| run: | | |
| [ -z "$CYBER_DISPATCH_TOKEN" ] && exit 0 | |
| curl -fsSL \ | |
| -X POST \ | |
| -H "Authorization: token $CYBER_DISPATCH_TOKEN" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/repos/cyberia-to/.github/dispatches \ | |
| -d '{"event_type":"content-changed"}' |