From 1c8c256dd27ec6e464161ef86a9c45308ded88bf Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:04:39 +0200 Subject: [PATCH 1/5] feat: add GitHub Actions workflow to recreate PRs in main repository --- .github/workflows/migrator.yml | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/migrator.yml diff --git a/.github/workflows/migrator.yml b/.github/workflows/migrator.yml new file mode 100644 index 00000000000..dec10ee20e5 --- /dev/null +++ b/.github/workflows/migrator.yml @@ -0,0 +1,58 @@ +# .github/workflows/recreate-pr.yml +name: Recreate PR in Main Repo + +on: + issue_comment: + types: [created] + +jobs: + recreate: + if: | + ( + github.event.issue.pull_request != null && + contains(github.event.comment.body, '@pyansys-ci-bot LGTM') && + 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/request-action@v2.x + 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-${{ github.event.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 #${{ github.event.issue.number }}" + body: "This PR was migrated from a fork to allow secrets to run in workflows." + branch: migrated/pr-${{ github.event.issue.number }} + base: ${{ steps.pr.outputs.data.base.ref }} From 5a79e890b910c793e2d8eaf2fdef8bfdd158668f Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Thu, 24 Apr 2025 09:07:19 +0000 Subject: [PATCH 2/5] chore: adding changelog file 3869.maintenance.md [dependabot-skip] --- doc/changelog.d/3869.maintenance.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/3869.maintenance.md diff --git a/doc/changelog.d/3869.maintenance.md b/doc/changelog.d/3869.maintenance.md new file mode 100644 index 00000000000..a766b171000 --- /dev/null +++ b/doc/changelog.d/3869.maintenance.md @@ -0,0 +1 @@ +feat: add GitHub Actions workflow to recreate PRs in main repository \ No newline at end of file From 53820e6607fd9898ba1359b2743acd6b7e15a5af Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:08:17 +0200 Subject: [PATCH 3/5] fix: update workflow name for clarity --- .github/workflows/migrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migrator.yml b/.github/workflows/migrator.yml index dec10ee20e5..4ea412d70ad 100644 --- a/.github/workflows/migrator.yml +++ b/.github/workflows/migrator.yml @@ -1,5 +1,5 @@ # .github/workflows/recreate-pr.yml -name: Recreate PR in Main Repo +name: Fork PR Handler on: issue_comment: From 963ec4a7ea1ad9fc92487fa987ad1cfcd0e9e5d6 Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:09:18 +0200 Subject: [PATCH 4/5] fix: update comment trigger for PR migration workflow --- .github/workflows/migrator.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/migrator.yml b/.github/workflows/migrator.yml index 4ea412d70ad..4ec61ed28d2 100644 --- a/.github/workflows/migrator.yml +++ b/.github/workflows/migrator.yml @@ -10,7 +10,7 @@ jobs: if: | ( github.event.issue.pull_request != null && - contains(github.event.comment.body, '@pyansys-ci-bot LGTM') && + contains(github.event.comment.body, '@pyansys-ci-bot migrate') && github.event.comment.user.login == 'germa89' ) || ( github.event_name == 'workflow_dispatch' ) runs-on: ubuntu-latest From 76a7127daa90bc711be540ff8beee9f6d9b79b0f Mon Sep 17 00:00:00 2001 From: German <28149841+germa89@users.noreply.github.com> Date: Thu, 24 Apr 2025 11:09:33 +0200 Subject: [PATCH 5/5] fix: use consistent output for migrated PR branch and title --- .github/workflows/migrator.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/migrator.yml b/.github/workflows/migrator.yml index 4ec61ed28d2..ee5fdc482d9 100644 --- a/.github/workflows/migrator.yml +++ b/.github/workflows/migrator.yml @@ -38,7 +38,7 @@ jobs: 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-${{ github.event.issue.number }} + NEW_BRANCH=migrated/pr-${{ steps.config.outputs.issue_number }} git clone $PR_HEAD_REPO pr-source cd pr-source @@ -52,7 +52,7 @@ jobs: uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - title: "Migrated PR #${{ github.event.issue.number }}" + 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-${{ github.event.issue.number }} + branch: migrated/pr-${{ steps.config.outputs.issue_number }} base: ${{ steps.pr.outputs.data.base.ref }}