-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: update cherry-pick for lts branch (#102)
- Loading branch information
1 parent
732bfd8
commit 7803d70
Showing
1 changed file
with
15 additions
and
10 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ on: | |
types: | ||
- closed | ||
branches: | ||
- 8.x.x | ||
- '[0-9]+.x.x' | ||
|
||
env: | ||
TARGET_BRANCH: main | ||
|
@@ -15,20 +15,20 @@ jobs: | |
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.TARGET_BRANCH }} | ||
fetch-depth: 0 | ||
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
|
||
- uses: actions/setup-node@v3 | ||
- uses: actions/setup-node@v4 | ||
id: setup-node | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Cache node modules | ||
id: cache | ||
uses: actions/cache@v3 | ||
uses: actions/cache@v4 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-modules-${{ hashFiles('package-lock.json') }} | ||
|
@@ -38,9 +38,11 @@ jobs: | |
run: npm ci | ||
|
||
- name: Cherry pick | ||
id: cherry-pick | ||
run: | | ||
git config user.name 'Blackbaud Sky Build User' | ||
git config user.email '[email protected]' | ||
# Set the git user to the author of the merge commit. | ||
git config user.name "$(git log -1 --pretty=format:'%an' ${{ github.event.pull_request.merge_commit_sha }})" | ||
git config user.email "$(git log -1 --pretty=format:'%ae' ${{ github.event.pull_request.merge_commit_sha }})" | ||
# Echo commands to the log. | ||
set -x | ||
|
@@ -71,15 +73,18 @@ jobs: | |
echo "CHERRY_PICK_RESULT=failed" >> $GITHUB_ENV | ||
exit 0 | ||
fi | ||
echo "commit_message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
|
||
- uses: actions/github-script@v6 | ||
- uses: actions/github-script@v7 | ||
if: ${{ env.CHERRY_PICK_RESULT != 'failed' }} | ||
with: | ||
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
script: | | ||
const pr = context.payload.pull_request; | ||
const title = ${{ toJson(steps.cherry-pick.outputs.commit_message) }}; | ||
let body = `:cherries: Cherry picked from #${pr.number} [${pr.title}](${pr.html_url})` | ||
const prAzureBoardLink = pr.body?.match(/(?<=\[)AB#\d+(?=])/g); | ||
if (prAzureBoardLink) { | ||
|
@@ -90,7 +95,7 @@ jobs: | |
repo: context.repo.repo, | ||
head: process.env.CHERRY_PICK_BRANCH, | ||
base: process.env.TARGET_BRANCH, | ||
title: `${pr.title} (#${pr.number})`, | ||
title, | ||
body | ||
}).then(result => { | ||
console.log(`Created PR #${result.data.number}: ${result.data.html_url}`); | ||
|
@@ -120,7 +125,7 @@ jobs: | |
- name: Comment on the original PR when cherry-pick is successful | ||
if: ${{ env.CHERRY_PICK_RESULT == 'success' }} | ||
uses: actions/github-script@v6 | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
script: | | ||
|
@@ -133,7 +138,7 @@ jobs: | |
- name: Comment on the original PR when cherry-pick fails | ||
if: ${{ env.CHERRY_PICK_RESULT != 'success' }} | ||
uses: actions/github-script@v6 | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
script: | | ||
|