Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Dec 4, 2024
1 parent 0d10237 commit c34ff55
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 23 deletions.
90 changes: 90 additions & 0 deletions .github/actions/backport/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
# Find the latest merge commit
MERGE_COMMIT=$(git rev-parse HEAD)
echo "merge commit: $MERGE_COMMIT"
echo "MERGE_COMMIT=$MERGE_COMMIT" >> $GITHUB_ENV
# echo "Looking for PR associated with commit ${{ github.sha }}..."
# Find the pull request associated with the merge commit
MAIN_HEAD="9c13c736316a5f9f5d63735482cccfe704b0fa67"
echo "Looking for PR associated with commit $MAIN_HEAD..."
PR=$(gh pr list --state merged --json number,title,headRefName,mergeCommit \
--jq ".[] | select(.mergeCommit == \"${{ github.sha }}\")")
if [[ -n "$PR" ]]; then
echo "Pull Request found:"
echo "$PR"
else
echo "No associated PR found for this commit."
fi
# Extract PR number and labels
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
echo "pr number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
LABELS=$(echo "$PR_JSON" | jq -r '.labels[].name')
echo "labels: $LABELS"
echo "LABELS=$LABELS" >> $GITHUB_ENV
# - name: Check for specified 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!"
34 changes: 11 additions & 23 deletions .github/workflows/backport-2.0.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
name: Backport to solana-v2.0-tmp

on:
# DELETE ME!
push:
branches:
- tmp
branches: [tmp]
pull_request:
branches: [tmp]

jobs:
backport:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Git Checkout
uses: actions/checkout@v4

- name: Fetch pull request data
id: pr_data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the latest commit hash on main
COMMIT_HASH=$(git rev-parse HEAD)
echo $COMMIT_HASH
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
# Find the pull request associated with the commit
PR_NUMBER=$(gh pr list --state merged --base main --json number,mergeCommit --jq ".[] | select(.mergeCommit == \"$COMMIT_HASH\").number")
echo $PR_NUMBER
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
# Fetch the labels for the PR
LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
echo $LABELS
echo "LABELS=$LABELS" >> $GITHUB_ENV
- name: Backport to v2.0
uses: ./.github/actions/backport
with:
label: v2.0
base_branch: solana-v2.0-tmp

0 comments on commit c34ff55

Please sign in to comment.