From 0dbe5a4a5528fe32e8ced81a292bcb700ddac25c Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:37:39 -0700 Subject: [PATCH 1/7] Switch from head ref to base ref in diff --- .github/workflows/update-downstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index 7e6e477..4ccadab 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -26,7 +26,7 @@ jobs: SOURCE_REPO: ${{ github.repository }} SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_PR_URL: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} - HEAD_REF: ${{ github.head_ref }} + BASE_REF: ${{ github.event.pull_request.base.ref }} HEAD_COMMIT_MSG: ${{ github.event.head_commit.message }} DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.head_ref }}..${{ github.sha }} GIT_USER: ${{ github.actor }} @@ -74,7 +74,7 @@ jobs: * Source ref: [`${{ env.REF }}`](${{ env.REF_URL }}) * Source pull request: [`${{ env.SOURCE_REPO }}#${{ env.SOURCE_PR_NUMBER }}`](${{ env.SOURCE_PR_URL }}) - * Source diff: [`${{ env.HEAD_REF }}..${{ env.REF }}`](${{ env.DIFF_URL }}) + * Source diff: [`${{ env.BASE_REF }}..${{ env.REF }}`](${{ env.DIFF_URL }}) push-to-fork: detsys-pr-bot/${{ matrix.repo }} branch: "${{ env.GIT_BRANCH }}" base: ${{ env.GIT_BASE }} From 2d82de87306b29c792a70e19d6848c6fef1b370a Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:42:43 -0700 Subject: [PATCH 2/7] Add separate step for commit message --- .github/workflows/update-downstream.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index 4ccadab..f3a39fc 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -25,9 +25,8 @@ jobs: REF_URL: https://github.com/${{ github.repository }}/tree/${{ github.sha }} SOURCE_REPO: ${{ github.repository }} SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} - SOURCE_PR_URL: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} + SOURCE_PR_URL: ${{ github.event.pull_request.html_url }} BASE_REF: ${{ github.event.pull_request.base.ref }} - HEAD_COMMIT_MSG: ${{ github.event.head_commit.message }} DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.head_ref }}..${{ github.sha }} GIT_USER: ${{ github.actor }} GIT_EMAIL: ${{ github.actor }}@users.noreply.github.com @@ -63,12 +62,20 @@ jobs: nix develop --command pnpm update detsys-ts nix develop --command pnpm all + - name: Get last commit message + id: commit-msg + run: | + MSG=$(git show -s --format=%s) + echo "msg=${MSG}" >> $GITHUB_OUTPUT + - name: Create Pull Request uses: peter-evans/create-pull-request@v3 + env: + COMMIT_MSG: ${{ steps.commit-msg.outputs.msg }} with: token: ${{ secrets.detsys_pr_bot_token }} - title: "Update `detsys-ts`: ${{ env.HEAD_COMMIT_MSG }}" - commit-message: "Update `detsys-ts` for: `${{ env.HEAD_COMMIT_MSG }}` (`${{ env.REF }}`)" + title: "Update `detsys-ts`: ${{ env.COMMIT_MSG }}" + commit-message: "Update `detsys-ts` for: `${{ env.COMMIT_MSG }}` (`${{ env.REF }}`)" body: | Bump [`detsys-ts`](${{ env.SOURCE_REPO }}) to the latest `HEAD` and regenerate application bundle. From dc1b59ef9e04ba1a5967125133a57b0ae7d8cea7 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:44:04 -0700 Subject: [PATCH 3/7] Fix diff URL --- .github/workflows/update-downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index f3a39fc..3fa8411 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -27,7 +27,7 @@ jobs: SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_PR_URL: ${{ github.event.pull_request.html_url }} BASE_REF: ${{ github.event.pull_request.base.ref }} - DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.head_ref }}..${{ github.sha }} + DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.sha }} GIT_USER: ${{ github.actor }} GIT_EMAIL: ${{ github.actor }}@users.noreply.github.com GIT_BRANCH: detsys-ts-update-${{ github.sha }} From c3fad04b212bc7d3d62f4119c4da9f1db6e63953 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:46:27 -0700 Subject: [PATCH 4/7] Provide idiomatic diff URL --- .github/workflows/update-downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index 3fa8411..c248719 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -27,7 +27,7 @@ jobs: SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_PR_URL: ${{ github.event.pull_request.html_url }} BASE_REF: ${{ github.event.pull_request.base.ref }} - DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.sha }} + DIFF_URL: ${{ github.event.pull_request.diff_url }} GIT_USER: ${{ github.actor }} GIT_EMAIL: ${{ github.actor }}@users.noreply.github.com GIT_BRANCH: detsys-ts-update-${{ github.sha }} From 14f26b533fffc7382e11c4dcd54cac20a912d410 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:51:09 -0700 Subject: [PATCH 5/7] Include both diff URLs --- .github/workflows/update-downstream.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index c248719..8e78355 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -27,7 +27,8 @@ jobs: SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_PR_URL: ${{ github.event.pull_request.html_url }} BASE_REF: ${{ github.event.pull_request.base.ref }} - DIFF_URL: ${{ github.event.pull_request.diff_url }} + DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.sha }} + DIFF_FILE_URL: ${{ github.event.pull_request.diff_url }} GIT_USER: ${{ github.actor }} GIT_EMAIL: ${{ github.actor }}@users.noreply.github.com GIT_BRANCH: detsys-ts-update-${{ github.sha }} @@ -82,6 +83,7 @@ jobs: * Source ref: [`${{ env.REF }}`](${{ env.REF_URL }}) * Source pull request: [`${{ env.SOURCE_REPO }}#${{ env.SOURCE_PR_NUMBER }}`](${{ env.SOURCE_PR_URL }}) * Source diff: [`${{ env.BASE_REF }}..${{ env.REF }}`](${{ env.DIFF_URL }}) + * Diff file: [`${{ env.SOURCE_PR_NUMBER }}.diff`](${{ env.DIFF_FILE_URL }}) push-to-fork: detsys-pr-bot/${{ matrix.repo }} branch: "${{ env.GIT_BRANCH }}" base: ${{ env.GIT_BASE }} From d1cef0367ac9dab8db25d366b2730416701a3b33 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:53:49 -0700 Subject: [PATCH 6/7] Run only if base is main --- .github/workflows/update-downstream.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index 8e78355..bf24ca4 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -7,7 +7,7 @@ on: jobs: update-downstream-repos: - if: ${{ github.event.pull_request.merged }} + if: ${{ github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' }} environment: detsys-pr-bot name: Pull request detsys-ts update to ${{ github.repository_owner }}/${{ matrix.repo }} runs-on: ubuntu-22.04 @@ -26,8 +26,8 @@ jobs: SOURCE_REPO: ${{ github.repository }} SOURCE_PR_NUMBER: ${{ github.event.pull_request.number }} SOURCE_PR_URL: ${{ github.event.pull_request.html_url }} - BASE_REF: ${{ github.event.pull_request.base.ref }} - DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.ref }}..${{ github.sha }} + BASE_REF: ${{ github.event.pull_request.base.sha }} + DIFF_URL: https://github.com/${{ github.repository }}/compare/${{ github.event.pull_request.base.sha }}..${{ github.sha }} DIFF_FILE_URL: ${{ github.event.pull_request.diff_url }} GIT_USER: ${{ github.actor }} GIT_EMAIL: ${{ github.actor }}@users.noreply.github.com From 5547fc0c42390f2527d6d9190f9537a0690829e7 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Wed, 5 Jun 2024 14:54:22 -0700 Subject: [PATCH 7/7] Make merged check more strict --- .github/workflows/update-downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-downstream.yml b/.github/workflows/update-downstream.yml index bf24ca4..fd935d2 100644 --- a/.github/workflows/update-downstream.yml +++ b/.github/workflows/update-downstream.yml @@ -7,7 +7,7 @@ on: jobs: update-downstream-repos: - if: ${{ github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' }} + if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' }} environment: detsys-pr-bot name: Pull request detsys-ts update to ${{ github.repository_owner }}/${{ matrix.repo }} runs-on: ubuntu-22.04