Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/cherry-pick-openedx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: cherry-pick target commit from openedx repo into fork

on:
workflow_dispatch:
inputs:
targetCommitHash:
description: 'Hash of the target commit to pull into the edX fork'
required: true
type: string

jobs:
cherry-pick:
name: Cherry pick file
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v5

- name: configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git remote add -f openedx https://github.com/openedx/frontend-app-learning.git
git remote rename origin edx

- name: check that commit exists and load commit info
id: commit-info
run: |
PRETTY=""
PRETTY+="hash=%h%n"
PRETTY+="commit_subject=%s%n"
PRETTY+="author_name=%an%n"
PRETTY+="author_email=%ae%n"
PRETTY+="date=%ad%n"

git log -1 --pretty=$PRETTY --remotes=openedx ${{ inputs.targetCommitHash }} >> $GITHUB_OUTPUT

- name: Cherry pick target commit onto new branch
run: |
BRANCH_NAME="${{ github.actor }}/cherry-pick-${{ steps.commit-info.outputs.hash }}"
git checkout -b $BRANCH_NAME
git cherry-pick ${{ inputs.targetCommitHash }} 2>&1 | tee cherry_pick_output
if [[ ${PIPESTATUS[0]} != 0 ]]; then
echo "## Unable to cherry-pick commit" >> $GITHUB_STEP_SUMMARY
cat cherry_pick_output >> $GITHUB_STEP_SUMMARY
exit 1
fi

git push -u edx $BRANCH_NAME 2>&1 | tee push_output
if [[ ${PIPESTATUS[0]} != 0 ]]; then
echo "## Unable to push to branch" >> $GITHUB_STEP_SUMMARY
cat push_output >> $GITHUB_STEP_SUMMARY
exit 1
fi

- name: Open pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
BODY=$(cat <<-EOF
This PR cherry-picks commit ${{ steps.commit-info.outputs.hash }} from the openedx repo into the edx fork.

Author: ${{ steps.commit-info.outputs.author_name }} <${{ steps.commit-info.outputs.author_email }}>
Date: ${{ steps.commit-info.outputs.date }}
EOF
)
gh pr create --title "${{ steps.commit-info.outputs.commit_subject }}" --body "$BODY" 1> pr_url 2> pr_errors
if [[ $? == 0 ]]; then
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ${PIPESTATUS[0]} instead of $? for consistency with the error handling pattern used in lines 43 and 50. This makes the error checking uniform throughout the workflow.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jansenk , this seems like a correct suggestion. Can you either commit or resolve this with reason not to change?

echo "## Pull Request Created! 🎉" >> $GITHUB_STEP_SUMMARY
echo $(cat pr_url) >> $GITHUB_STEP_SUMMARY
else
echo "## Pull request creation failed" >> $GITHUB_STEP_SUMMARY
echo $(cat pr_errors) >> $GITHUB_STEP_SUMMARY
exit 1
fi