Ensure the cherry pick operation only executes against `trunk` (#47312)

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-release-highlight-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update README.md

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update test-assistant-api-rest-change-tracker.yml

* Update cherry pick workflow to only execute against trunk

* Update workflow to add safety checks before accessing nested properties

* Update workflow to add safety checks before accessing nested properties

* log outputs for debugging

* log outputs for debugging

* log outputs for debugging

* log outputs for debugging

* log outputs for debugging

* log outputs for debugging

* log outputs for debugging

* sync files pre PR
This commit is contained in:
nigeljamesstevenson 2024-05-11 22:15:53 +01:00 committed by GitHub
parent 1ce0f14de2
commit 0cd8740a85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 3 deletions

View File

@ -39,18 +39,34 @@ jobs:
outputs: outputs:
run: ${{ steps.check.outputs.run }} run: ${{ steps.check.outputs.run }}
steps: steps:
- name: Fetch Pull Request Details
if: github.event.issue.pull_request
id: fetch_pr_details
uses: actions/github-script@v6
with:
script: |
const issue = context.payload.issue;
const pullRequestUrl = issue.pull_request.url;
const prDetails = await github.request(pullRequestUrl);
core.setOutput('base_ref', prDetails.data.base.ref);
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check - name: check
id: check id: check
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
script: | script: |
const baseRef = process.env.BASE_REF;
console.log("baseRef:", baseRef);
let run = false; let run = false;
const isManualTrigger = context.payload.inputs && context.payload.inputs.release_branch && context.payload.inputs.release_branch != null; const isManualTrigger = context.payload.inputs && context.payload.inputs.release_branch && context.payload.inputs.release_branch != null;
const isMergedMilestonedIssue = context.payload.issue && context.payload.issue.pull_request != null && context.payload.issue.pull_request.merged_at != null && context.payload.issue.milestone != null; const isMergedMilestonedIssue = context.payload.issue && context.payload.issue.pull_request != null && context.payload.issue.pull_request.merged_at != null && context.payload.issue.milestone != null && baseRef == 'trunk';
const isMergedMilestonedPR = context.payload.pull_request && context.payload.pull_request != null && context.payload.pull_request.merged == true && context.payload.pull_request.milestone != null; const isMergedMilestonedPR = context.payload.pull_request && context.payload.pull_request != null && context.payload.pull_request.merged == true && context.payload.pull_request.milestone != null && baseRef == 'trunk';
const isBot = context.payload.pull_request && ( context.payload.pull_request.user.login == 'github-actions[bot]' || context.payload.pull_request.user.type == 'Bot' ); const isBot = context.payload.pull_request && ( context.payload.pull_request.user.login == 'github-actions[bot]' || context.payload.pull_request.user.type == 'Bot' );
@ -59,6 +75,9 @@ jobs:
} else { } else {
core.setOutput( 'run', 'false' ); core.setOutput( 'run', 'false' );
} }
env:
BASE_REF: ${{ steps.fetch_pr_details.outputs.base_ref }}
prep: prep:
name: Prep inputs name: Prep inputs
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
@ -363,4 +382,4 @@ jobs:
Release lead please review: Release lead please review:
${{ steps.cherry-pick-pr.outputs.cherry-pick-pr }} ${{ steps.cherry-pick-pr.outputs.cherry-pick-pr }}
${{ steps.deletion-pr.outputs.deletion-pr }} ${{ steps.deletion-pr.outputs.deletion-pr }}