-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release automation: try cherry-picking automation
- Loading branch information
Showing
1 changed file
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Auto Cherry-Pick | ||
|
||
on: | ||
pull_request: | ||
types: [closed, labeled] | ||
branches: | ||
- try/cherry-pick-automation-trunk # To be replaced with "trunk". | ||
|
||
jobs: | ||
cherry-pick: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged == true | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name "Gutenberg Repository Automation" | ||
git config --global user.email "gutenberg@wordpress.org" | ||
- name: Determine if label should trigger cherry-pick | ||
id: label-check | ||
run: | | ||
LABELS=$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH") | ||
for LABEL in $LABELS; do | ||
if [[ "$LABEL" =~ ^Backport\ to\ WP\ ([0-9]+\.[0-9]+)\ Beta/RC$ ]]; then | ||
VERSION=${BASH_REMATCH[1]} | ||
echo "::set-output name=cherry_pick::true" | ||
echo "::set-output name=version::$VERSION" | ||
exit 0 | ||
fi | ||
done | ||
echo "::set-output name=cherry_pick::false" | ||
- name: Cherry-pick the commit | ||
id: cherry-pick | ||
if: steps.label-check.outputs.cherry_pick == 'true' | ||
run: | | ||
TARGET_BRANCH="wp/${{ steps.label-check.outputs.version }}" | ||
COMMIT_SHA=$(jq -r '.pull_request.merge_commit_sha' "$GITHUB_EVENT_PATH") | ||
git checkout $TARGET_BRANCH | ||
git cherry-pick $COMMIT_SHA || echo "cherry-pick-failed" > result | ||
if [ -f result ] && grep -q "cherry-pick-failed" result; then | ||
echo "::set-output name=conflict::true" | ||
git cherry-pick --abort | ||
else | ||
git push origin $TARGET_BRANCH | ||
echo "::set-output name=conflict::false" | ||
fi | ||
- name: Remove cherry-pick label | ||
if: steps.label-check.outputs.cherry_pick == 'true' && steps.cherry-pick.outputs.conflict == 'false' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const prNumber = ${{ github.event.pull_request.number }}; | ||
const label = `Backport to WP ${{ steps.label-check.outputs.version }} Beta/RC`; | ||
await github.issues.removeLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
name: label | ||
}); | ||
- name: Comment on the PR | ||
if: steps.label-check.outputs.cherry_pick == 'true' && steps.cherry-pick.outputs.conflict == 'false' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const prNumber = ${{ github.event.pull_request.number }}; | ||
const commitSha = '${{ steps.cherry-pick.outputs.commit_sha }}'; | ||
const targetBranch = `wp/${{ steps.label-check.outputs.version }}`; | ||
await github.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
body: `I just cherry-picked this PR to the ${targetBranch} branch to get it included in the next release: ${commitSha}` | ||
}); | ||
- name: Comment on the PR about conflict | ||
if: steps.label-check.outputs.cherry_pick == 'true' && steps.cherry-pick.outputs.conflict == 'true' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const prNumber = ${{ github.event.pull_request.number }}; | ||
const targetBranch = `wp/${{ steps.label-check.outputs.version }}`; | ||
await github.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
body: `There was a conflict while trying to cherry-pick the commit to the ${targetBranch} branch. Please resolve the conflict manually and create a PR to the ${targetBranch} branch.` | ||
}); |
37d701f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 37d701f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9609634591
📝 Reported issues:
/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js