-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d10237
commit e7b7606
Showing
2 changed files
with
91 additions
and
22 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,82 @@ | ||
name: Backport | ||
description: Backport changes to another release branch. | ||
inputs: | ||
label: | ||
description: The trigger label (i.e., v2.0, v1.18) | ||
required: true | ||
base_branch: | ||
description: The base branch to backport to (i.e., solana-v2.0, solana-v1.18) | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Fetch pull request data | ||
id: pr_data | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Find the latest merge commit | ||
MERGE_COMMIT=$(git rev-parse HEAD) | ||
echo "MERGE_COMMIT=$MERGE_COMMIT" >> $GITHUB_ENV | ||
# Find the pull request associated with the merge commit | ||
PR_JSON=$(gh pr list --state merged --base main --json number,mergeCommit,labels --jq ".[] | select(.mergeCommit == \"$MERGE_COMMIT\")") | ||
if [ -z "$PR_JSON" ]; then | ||
echo "No pull request found for merge commit $MERGE_COMMIT." | ||
exit 1 | ||
fi | ||
# Extract PR number and labels | ||
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number') | ||
LABELS=$(echo "$PR_JSON" | jq -r '.labels[].name') | ||
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | ||
echo "LABELS=$LABELS" >> $GITHUB_ENV | ||
# - name: Check for specified label | ||
# id: check_label | ||
# run: | | ||
# echo "Checking labels: $LABELS" | ||
# if echo "$LABELS" | grep -q "${{ inputs.label }}"; then | ||
# echo "BACKPORT=true" >> $GITHUB_ENV | ||
# else | ||
# echo "BACKPORT=false" >> $GITHUB_ENV | ||
# fi | ||
|
||
# - name: Backport changes | ||
# if: ${{ env.BACKPORT == 'true' }} | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# run: | | ||
# # Set up Git user | ||
# git config user.name "github-actions[bot]" | ||
# git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
||
# # Fetch all branches | ||
# git fetch --all | ||
|
||
# # Create a new branch off the specified base branch | ||
# BASE_BRANCH="${{ inputs.base_branch }}" | ||
# BACKPORT_BRANCH="backport-${{ env.PR_NUMBER }}-to-${{ inputs.base_branch }}" | ||
# git checkout $BASE_BRANCH | ||
# git checkout -b $BACKPORT_BRANCH | ||
|
||
# # Cherry-pick the merge commit | ||
# git cherry-pick $MERGE_COMMIT || (git cherry-pick --abort && exit 1) | ||
|
||
# # Push the new branch | ||
# git push origin $BACKPORT_BRANCH | ||
|
||
# # Create a pull request | ||
# gh pr create \ | ||
# --base $BASE_BRANCH \ | ||
# --head $BACKPORT_BRANCH \ | ||
# --title "Backport PR #${{ env.PR_NUMBER }} to $BASE_BRANCH" \ | ||
# --body "This is an automated backport of PR #${{ env.PR_NUMBER }} to the $BASE_BRANCH branch." | ||
# outputs: | ||
# result: "Backport successful!" |
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