Create release PR #14
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: Create release PR | |
| on: | |
| workflow_run: | |
| workflows: ["Update and test"] | |
| types: [completed] | |
| workflow_dispatch: | |
| inputs: | |
| run_id: | |
| description: 'Workflow run ID to process' | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| create-pr: | |
| runs-on: [self-hosted, Linux] | |
| if: github.event.workflow_run.head_branch == 'main' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| - name: Install devenv | |
| run: nix profile install github:cachix/devenv/latest | |
| - name: Get nixpkgs revision | |
| id: nixpkgs | |
| run: | | |
| SHORT=$(nix flake metadata --json | jq -r '.locks.nodes["nixpkgs-src"].locked.rev' | cut -c1-7) | |
| echo "short=$SHORT" >> "$GITHUB_OUTPUT" | |
| - name: Generate test summary | |
| shell: devenv shell bash -- -e {0} | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| RUN_ID="${{ inputs.run_id }}" | |
| RUN_URL="https://github.com/${{ github.repository }}/actions/runs/$RUN_ID" | |
| else | |
| RUN_ID="${{ github.event.workflow_run.id }}" | |
| RUN_URL="${{ github.event.workflow_run.html_url }}" | |
| fi | |
| test-summary --run-id "$RUN_ID" --run-url "$RUN_URL" --repo "${{ github.repository }}" --output-path test-summary.md | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Read test summary | |
| id: summary | |
| run: | | |
| { | |
| echo 'body<<SUMMARY_EOF' | |
| echo "Promotes main to rolling with nixpkgs ${{ steps.nixpkgs.outputs.short }}." | |
| echo "" | |
| echo "## Test Results" | |
| echo "" | |
| cat test-summary.md | |
| echo "" | |
| echo "---" | |
| echo "Auto-generated release PR." | |
| echo 'SUMMARY_EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Ensure rolling branch exists | |
| run: | | |
| if ! git ls-remote --exit-code origin rolling; then | |
| git push origin main:rolling | |
| fi | |
| - name: Create or update release PR | |
| run: | | |
| TITLE="Release nixpkgs ${{ steps.nixpkgs.outputs.short }}" | |
| PR_URL=$(gh pr list --base rolling --head main --json url --jq '.[0].url') | |
| if [ -n "$PR_URL" ]; then | |
| gh pr edit "$PR_URL" --title "$TITLE" --body "$BODY" | |
| else | |
| gh pr create --base rolling --head main --title "$TITLE" --body "$BODY" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BODY: ${{ steps.summary.outputs.body }} |