-
Notifications
You must be signed in to change notification settings - Fork 3
feat: action for cherry-picking from openedx #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-teak
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
||
| 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 | ||
Uh oh!
There was an error while loading. Please reload this page.