sync-flake-lock-and-rust-toolchain #31
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: sync-flake-lock-and-rust-toolchain | |
| on: | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: bash -xe {0} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-flake-lock: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - name: Sync flake.lock and rust-toolchain.toml from upstream | |
| run: | | |
| curl https://raw.githubusercontent.com/obeli-sk/obelisk/refs/heads/latest/flake.lock -o flake.lock | |
| UPSTREAM=https://raw.githubusercontent.com/obeli-sk/obelisk/refs/heads/latest/rust-toolchain.toml | |
| CHANNEL=$(curl -fsSL "$UPSTREAM" | grep '^channel =') | |
| sed -i "s/^channel =.*/$CHANNEL/" rust-toolchain.toml | |
| - uses: nixbuild/nix-quick-install-action@v34 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| nix_conf: | | |
| extra-substituters = https://cache.garnix.io | |
| extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g | |
| - name: Populate the nix store | |
| run: | | |
| nix develop --command echo | |
| - name: Update dev-deps.txt | |
| run: | | |
| nix develop . --command ./scripts/dev-deps.sh | |
| - name: Generate wit support and extensions | |
| run: | | |
| nix develop . --command ./scripts/obelisk-generate-wit-support.sh | |
| nix develop . --command ./scripts/dev-deps.sh | |
| - name: Generate Unique Branch Name | |
| id: branch-name | |
| run: echo "branch_name=sync-flake-lock-$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit Changes | |
| run: | | |
| git checkout -b ${{ steps.branch-name.outputs.branch_name }} | |
| git add . | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git commit -m 'chore: Sync `flake.lock` from upstream' | |
| git push origin ${{ steps.branch-name.outputs.branch_name }} | |
| OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1) | |
| REPO=$(echo "${{ github.repository }}" | cut -d'/' -f2) | |
| curl -v --fail -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/$OWNER/$REPO/pulls \ | |
| -d '{ | |
| "title": "Sync `flake.lock` from upstream", | |
| "head": "'${{ steps.branch-name.outputs.branch_name }}'", | |
| "base": "main", | |
| "body": "" | |
| }' | |
| else | |
| echo "No changes to commit." | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PR_RW }} | |