Skip to content

Commit

Permalink
Ensure the cherry pick operation only executes against trunk (#47312)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nigeljamesstevenson committed May 11, 2024
1 parent 1ce0f14 commit 0cd8740
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/cherry-pick.yml
Expand Up @@ -39,18 +39,34 @@ jobs:
outputs:
run: ${{ steps.check.outputs.run }}
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
id: check
uses: actions/github-script@v6
with:
script: |
const baseRef = process.env.BASE_REF;
console.log("baseRef:", baseRef);
let run = false;
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' );
Expand All @@ -59,6 +75,9 @@ jobs:
} else {
core.setOutput( 'run', 'false' );
}
env:
BASE_REF: ${{ steps.fetch_pr_details.outputs.base_ref }}

prep:
name: Prep inputs
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -363,4 +382,4 @@ jobs:
Release lead please review:
${{ steps.cherry-pick-pr.outputs.cherry-pick-pr }}
${{ steps.deletion-pr.outputs.deletion-pr }}
${{ steps.deletion-pr.outputs.deletion-pr }}

0 comments on commit 0cd8740

Please sign in to comment.