Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 21, 2024
1 parent 0761668 commit af94f15
Showing 1 changed file with 39 additions and 19 deletions.
58 changes: 39 additions & 19 deletions .github/workflows/cherry-pick-wp-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,37 @@ jobs:
- name: Determine if label should trigger cherry-pick
id: label-check
run: |
LABELS=$(jq -r '.pull_request.labels[].name' "$GITHUB_EVENT_PATH")
echo "$LABELS"
for LABEL in $LABELS; do
if [[ "$LABEL" =~ ^Backport\ to\ WP\ ([0-9]+\.[0-9]+)\ Beta/RC$ ]]; then
VERSION=${BASH_REMATCH[1]}
echo "cherry_pick=true" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_ENV
exit 0
fi
done
echo "cherry_pick=false" >> $GITHUB_ENV
uses: actions/github-script@v6
with:
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
console.log(`Labels: ${labels}`);
const regex = /^Backport to WP ([0-9]+\.[0-9]+) Beta\/RC$/;
let matched = false;
for (const label of labels) {
const match = label.match(regex);
if (match) {
const version = match[1];
console.log(`Matched label: ${label}`);
console.log(`Extracted version: ${version}`);
core.exportVariable('cherry_pick', 'true');
core.exportVariable('version', version);
matched = true;
break;
}
}
if (!matched) {
core.exportVariable('cherry_pick', 'false');
}
- name: Cherry-pick the commit
id: cherry-pick
if: env.cherry_pick == 'true'
run: |
TARGET_BRANCH="wp/${{ env.version }}"
COMMIT_SHA=$(jq -r '.pull_request.merge_commit_sha' "$GITHUB_EVENT_PATH")
echo "Target branch: $TARGET_BRANCH"
echo "Commit SHA: $COMMIT_SHA"
git checkout $TARGET_BRANCH
git cherry-pick $COMMIT_SHA || echo "cherry-pick-failed" > result
if [ -f result ] && grep -q "cherry-pick-failed" result; then
Expand All @@ -57,8 +69,11 @@ jobs:
uses: actions/github-script@v6
with:
script: |
const prNumber = ${{ github.event.pull_request.number }};
const label = `Backport to WP ${{ env.version }} Beta/RC`;
const prNumber = context.issue.number;
const version = process.env.version;
console.log(`prNumber: ${prNumber}`);
console.log(`version: ${version}`);
const label = `Backport to WP ${version} Beta/RC`;
await github.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -71,9 +86,12 @@ jobs:
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/${{ env.version }}`;
const prNumber = context.issue.number;
const commitSha = process.env.commit_sha;
const targetBranch = `wp/${process.env.version}`;
console.log(`prNumber: ${prNumber}`);
console.log(`commitSha: ${commitSha}`);
console.log(`targetBranch: ${targetBranch}`);
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -86,8 +104,10 @@ jobs:
uses: actions/github-script@v6
with:
script: |
const prNumber = ${{ github.event.pull_request.number }};
const targetBranch = `wp/${{ env.version }}`;
const prNumber = context.issue.number;
const targetBranch = `wp/${process.env.version}`;
console.log(`prNumber: ${prNumber}`);
console.log(`targetBranch: ${targetBranch}`);
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down

0 comments on commit af94f15

Please sign in to comment.