Skip to content
Merged
Show file tree
Hide file tree
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
58 changes: 58 additions & 0 deletions .github/workflows/migrator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# .github/workflows/recreate-pr.yml
name: Fork PR Handler

on:
issue_comment:
types: [created]

jobs:
recreate:
if: |
(
github.event.issue.pull_request != null &&
contains(github.event.comment.body, '@pyansys-ci-bot migrate') &&
github.event.comment.user.login == 'germa89'
) || ( github.event_name == 'workflow_dispatch' )
runs-on: ubuntu-latest
steps:
- name: "Configuration"
id: config
run: |
if [[ ${{ github.event_name }} == "workflow_dispatch" ]] ; then
echo "On workflow dispatch"
echo "issue_number=${{ inputs.issue_number }}" >> $GITHUB_OUTPUT
else
echo "On ${{ github.event_name }}"
echo "issue_number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
fi;

- name: Get PR info
id: pr
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/pulls/${{ steps.config.outputs.issue_number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Clone PR branch from fork
run: |
PR_HEAD_REPO=${{ steps.pr.outputs.data.head.repo.clone_url }}
PR_HEAD_REF=${{ steps.pr.outputs.data.head.ref }}
NEW_BRANCH=migrated/pr-${{ steps.config.outputs.issue_number }}

git clone $PR_HEAD_REPO pr-source
cd pr-source
git checkout $PR_HEAD_REF
git config --global user.name "${{ secrets.PYANSYS_CI_BOT_USERNAME }}"
git config --global user.email "${{ secrets.PYANSYS_CI_BOT_EMAIL}}"
git remote add dest https://x-access-token:${{ secrets.PYANSYS_CI_BOT_TOKEN }}@github.com/${{ github.repository }}.git
git push dest HEAD:refs/heads/$NEW_BRANCH

- name: Create new PR
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
title: "Migrated PR #${{ steps.config.outputs.issue_number }}"
body: "This PR was migrated from a fork to allow secrets to run in workflows."
branch: migrated/pr-${{ steps.config.outputs.issue_number }}
base: ${{ steps.pr.outputs.data.base.ref }}
1 change: 1 addition & 0 deletions doc/changelog.d/3869.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: add GitHub Actions workflow to recreate PRs in main repository
Loading