diff --git a/.github/workflows/on_new_pr.yml b/.github/workflows/on_new_pr.yml index 04c9e98b..54b87093 100644 --- a/.github/workflows/on_new_pr.yml +++ b/.github/workflows/on_new_pr.yml @@ -17,6 +17,12 @@ on: permissions: contents: read +# NOTE: pull_request_target resolves local composite actions from the filesystem rather than git +# storage, and since the workspace is empty at job initialisation (before any steps run), local +# uses: ./.github/actions/... references will always fail — even with an actions/checkout step, +# because step execution happens after action path resolution. As a result, any steps in this +# workflow that would otherwise use local composite actions must inline their logic directly. + jobs: enable-auto-merge: runs-on: ubuntu-latest @@ -29,10 +35,33 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'dependencies') steps: - name: "Auto Merge" - uses: ./.github/actions/enable-automerge + uses: actions/github-script@v9.0.0 with: github-token: ${{secrets.SOURCE_PUSH_TOKEN}} - merge-method: "MERGE" + script: | + const mergeMethod = process.env.MERGE_METHOD; + const nodeId = context.payload.pull_request.node_id; + await github.graphql(` + mutation EnableAutoMerge($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) { + enablePullRequestAutoMerge(input: { + pullRequestId: $pullRequestId, + mergeMethod: $mergeMethod + }) { + pullRequest { + autoMergeRequest { + mergeMethod + } + } + } + } + `, { + pullRequestId: nodeId, + mergeMethod: mergeMethod, + }); + core.info(`✅ Enabled auto-merge (${mergeMethod}) on PR #${context.payload.pull_request.number}`); + core.notice(`Enabled auto-merge (${mergeMethod}) on PR #${context.payload.pull_request.number}`); + env: + MERGE_METHOD: "MERGE" auto_approve_dependabot: runs-on: ubuntu-latest @@ -44,6 +73,15 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'dependencies') steps: - name: "Auto Approve" - uses: ./.github/actions/approve-pr + uses: actions/github-script@v9.0.0 with: github-token: ${{secrets.SOURCE_PUSH_TOKEN}} + script: | + await github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + event: 'APPROVE', + }); + core.info(`✅ Approved PR #${context.payload.pull_request.number}`); + core.notice(`Approved PR #${context.payload.pull_request.number}`); diff --git a/CHANGELOG.md b/CHANGELOG.md index ac634077..b5829c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release - Replace raw echo with output helpers in git/mkmissing-release - Replace raw echo with output helpers in git/init-preview - Replace raw echo with output helpers in git/clone-repos +- Inline enable-auto-merge and auto-approve scripts in Pull Request workflow to fix pull_request_target local action resolution failure ### Changed - Replace raw echo with standard output helpers (die/info/success) in github/cancel-workflows - Replace raw echo with standard output helpers (die/info/success) in git/update-repos-personal