ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
at rollback-hacking 74 lines 2.3 kB view raw
1--- 2name: "PR Preview" 3on: 4 push: 5jobs: 6 get-pr: 7 runs-on: ubuntu-latest 8 outputs: 9 number: ${{ steps.find-pr.outputs.number }} 10 if: ${{ github.actor != 'dependabot[bot]' }} 11 steps: 12 - uses: jwalton/gh-find-current-pr@master 13 id: find-pr 14 with: 15 state: all 16 base-ref: 17 runs-on: ubuntu-latest 18 needs: get-pr 19 outputs: 20 base-ref: ${{ steps.base-ref.outputs.base-ref }} 21 if: ${{ needs.get-pr.outputs.number != '' }} 22 steps: 23 - run: sudo apt install -y jq 24 - name: Locate Base Ref 25 id: base-ref 26 run: | 27 echo "base-ref=$(gh api /repos/${{ github.repository }}/pulls/${{ needs.get-pr.outputs.number }} | jq -r '.base.ref')" >> "$GITHUB_OUTPUT" 28 env: 29 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 eval-base: 31 runs-on: ubuntu-latest 32 needs: base-ref 33 outputs: 34 drv: ${{ steps.drv.outputs.drv }} 35 steps: 36 - uses: actions/checkout@v6 37 with: 38 ref: ${{ needs.base-ref.outputs.base-ref }} 39 - uses: ./.github/actions/setup-nix 40 - id: drv 41 run: echo "drv=$(nix eval .#docs --json)" >> "$GITHUB_OUTPUT" 42 eval-head: 43 runs-on: ubuntu-latest 44 needs: get-pr 45 outputs: 46 drv: ${{ steps.drv.outputs.drv }} 47 if: ${{ needs.get-pr.outputs.number != '' }} 48 steps: 49 - uses: actions/checkout@v6 50 - uses: ./.github/actions/setup-nix 51 - id: drv 52 run: echo "drv=$(nix eval .#docs --json)" >> "$GITHUB_OUTPUT" 53 deploy: 54 runs-on: ubuntu-latest 55 needs: 56 - eval-head 57 - eval-base 58 - get-pr 59 environment: 60 name: pr-${{ needs.get-pr.outputs.number }} 61 url: https://pr-${{ needs.get-pr.outputs.number }}.wire-docs.pages.dev/ 62 # skip if nothing changed in the docs package 63 if: needs.eval-head.outputs.drv != needs.eval-base.outputs.drv 64 steps: 65 - uses: actions/checkout@v6 66 - uses: ./.github/actions/setup-nix 67 - run: nix build .#docs 68 - name: Deploy to Cloudflare Pages 69 id: deployment 70 uses: cloudflare/wrangler-action@v3 71 with: 72 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} 73 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} 74 command: pages deploy ./result/ --project-name wire-docs --branch pr-${{ needs.get-pr.outputs.number }}