Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Dec 4, 2024
1 parent 5fd85d8 commit 1895a82
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
50 changes: 26 additions & 24 deletions .github/actions/backport/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,39 @@ inputs:
runs:
using: "composite"
steps:
- name: Fetch pull request data
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
MERGE_COMMIT=${{ github.sha }}
echo "MERGE_COMMIT=$MERGE_COMMIT" >> $GITHUB_ENV
# - name: Fetch pull request data
# env:
# GH_TOKEN: ${{ github.token }}
# shell: bash
# run: |
# MERGE_COMMIT=${{ github.sha }}
# echo "MERGE_COMMIT=$MERGE_COMMIT" >> $GITHUB_ENV

echo "Looking for PR associated with commit $MERGE_COMMIT... with label ${{ inputs.label }}"
PR=$(gh pr list --state merged --json number,title,headRefName,mergeCommit,labels \
--jq ".[] | select(.mergeCommit.oid == \"$MERGE_COMMIT\" and (.labels[].name | contains(\"${{ inputs.label }}\")))")
# echo "Looking for PR associated with commit $MERGE_COMMIT... with label ${{ inputs.label }}"
# PR=$(gh pr list --state merged --json number,title,headRefName,mergeCommit,labels \
# --jq ".[] | select(.mergeCommit.oid == \"$MERGE_COMMIT\" and (.labels[].name | contains(\"${{ inputs.label }}\")))")

if [[ -n "$PR" ]]; then
echo "Pull Request found:"
echo "$PR"
# if [[ -n "$PR" ]]; then
# echo "Pull Request found:"
# echo "$PR"

PR_NUMBER=$(echo $PR | jq -r '.number')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
# PR_NUMBER=$(echo $PR | jq -r '.number')
# echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV

echo "Will backport to ${{ inputs.base_branch }}"
echo "BACKPORT=true" >> $GITHUB_ENV
else
echo "No backport detected."
fi
# echo "Will backport to ${{ inputs.base_branch }}"
# echo "BACKPORT=true" >> $GITHUB_ENV
# else
# echo "No backport detected."
# fi

- name: Backport changes
if: ${{ env.BACKPORT == 'true' }}
env:
GITHUB_TOKEN: ${{ github.token }}
shell: bash
run: |
MERGE_COMMIT="461510a10cb3a9f58db6d5d9a4190bbc48051305"
PR_NUMBER="69"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -51,13 +53,13 @@ runs:
BASE_BRANCH="${{ inputs.base_branch }}"
BACKPORT_BRANCH="backport-${{ env.PR_NUMBER }}-to-${{ inputs.base_branch }}"
git checkout $BASE_BRANCH
git pull origin $BASE_BRANCH
git checkout -b $BACKPORT_BRANCH
BACKPORT_BRANCH="backport-${{ env.PR_NUMBER }}-to-${{ inputs.base_branch }}"
BACKPORT_BRANCH="backport-${{ github.sha }}-to-${{ inputs.base_branch }}"
git checkout -b $BACKPORT_BRANCH
git cherry-pick $MERGE_COMMIT || (git cherry-pick --abort && exit 1)
git cherry-pick -X ours $MERGE_COMMIT
git cherry-pick --continue || git commit --allow-empty -m "cherry-pick was empty"
git push origin $BACKPORT_BRANCH
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/backport-2.0.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Backport to solana-v2.0

on:
pull_request:
branches: [main]
push:
branches: [main]

Expand Down

0 comments on commit 1895a82

Please sign in to comment.