Skip to content

Commit bb5e036

Browse files
committed
Enhance GitHub Actions workflow for PR previews by adding Git user setup and branch push for external repositories
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 21008b0 commit bb5e036

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/static.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,22 @@ jobs:
4747
# Upload just the public folder
4848
path: 'public'
4949
- name: Deploy to GitHub Pages
50+
if: github.event.pull_request.head.repo.full_name == github.repository
5051
id: deployment
5152
uses: actions/deploy-pages@v4
53+
54+
- name: Set up Git user
55+
if: github.event.pull_request.head.repo.full_name != github.repository
56+
run: |
57+
git config user.name "l5io"
58+
git config user.email "l5io@users.noreply.github.com"
59+
- name: Push branch to master repo
60+
if: github.event.pull_request.head.repo.full_name != github.repository
61+
run: |
62+
git remote add main-origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
63+
git push main-origin HEAD:refs/heads/pr-preview/${{ github.event.pull_request.number }} --force
64+
65+
5266
- name: Comment Preview URL on PR
5367
if: github.event_name == 'pull_request'
5468
uses: marocchino/sticky-pull-request-comment@v2
@@ -61,3 +75,24 @@ jobs:
6175
> 📖 General Preview: ${{ steps.deployment.outputs.page_url }}
6276
6377
This preview will be updated automatically when you push new commits to this PR.
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
# mirror-fork-pr:
88+
# if: github.event.pull_request.head.repo.full_name != github.repository
89+
# environment:
90+
# name: pr-preview-${{ github.event.pull_request.number || github.run_id }}
91+
# # url: ${{ steps.deployment.outputs.page_url }}
92+
# runs-on: ubuntu-latest
93+
# steps:
94+
# - name: Checkout PR branch
95+
# uses: actions/checkout@v4
96+
# with:
97+
# ref: ${{ github.event.pull_request.head.ref }}
98+
# repository: ${{ github.event.pull_request.head.repo.full_name }}

0 commit comments

Comments
 (0)