Skip to content

Commit

Permalink
Create builds-preview.yml
Browse files Browse the repository at this point in the history
Signed-off-by: thefourCraft <[email protected]>
  • Loading branch information
thefourcraft authored Mar 15, 2024
1 parent 27128bc commit 63dd7bf
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/builds-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Fork PR Handler with GitHub CLI

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
handle-fork-pr:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == true
steps:
- name: Checkout code from the fork's PR
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Configure Git
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Create and push new branch
run: |
NEW_BRANCH="build-${{ github.event.pull_request.number }}"
git checkout -b $NEW_BRANCH
git push origin $NEW_BRANCH
- name: Create PR in original repository
run: |
gh pr create \
--title "Automated PR for changes from fork #${{ github.event.pull_request.number }}" \
--body "This is an automated PR to merge changes from the fork's PR #${{ github.event.pull_request.number }}" \
--base production \
--head ${{ github.repository }}:$NEW_BRANCH \
--repo ${{ github.repository }} \
--label "automated-pr" \
--reviewer "team_reviewers" \
--assignee "@me"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 63dd7bf

Please sign in to comment.