Skip to content

Commit 782f2e4

Browse files
fixed preview workflow (#463)
* testing preview workflow * testing preview workflow 2 * testing preview workflow 3 * testing preview workflow 4 * testing preview workflow 5 * testing preview workflow 6 * testing preview workflow 6 * testing preview workflow 6 * new preview test * new preview test 1 * final workflow * final workflow --------- Co-authored-by: Shravan Goswami <shravanngoswamii.com>
1 parent 5871974 commit 782f2e4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/preview.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PR Preview Workflow
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types:
66
- opened
77
- synchronize
@@ -13,7 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
1719

1820
- name: Setup Julia
1921
uses: julia-actions/setup-julia@v2
@@ -46,26 +48,33 @@ jobs:
4648
_freeze/
4749
key: ${{ runner.os }}-primes-${{ github.run_id }}
4850

51+
- name: Checkout gh-pages branch
52+
uses: actions/checkout@v3
53+
with:
54+
ref: gh-pages
55+
path: gh-pages
56+
4957
- name: Deploy Preview to GitHub Pages
5058
run: |
5159
PR_NUMBER=${{ github.event.pull_request.number }}
5260
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
53-
git config --global user.name "github-actions[bot]"
54-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
55-
git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
5661
mkdir -p gh-pages/${PREVIEW_DIR}
5762
cp -r _site/* gh-pages/${PREVIEW_DIR}
5863
cd gh-pages
64+
git config --global user.name "github-actions[bot]"
65+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
5966
git add .
6067
git commit -m "Deploy preview for PR ${PR_NUMBER}"
6168
git push
69+
env:
70+
GH_PAT: ${{ secrets.GH_PAT }}
6271

6372
delete-preview-directory:
6473
if: github.event.action == 'closed' || github.event.pull_request.merged == true
6574
runs-on: ubuntu-latest
6675
steps:
6776
- name: Checkout gh-pages branch
68-
uses: actions/checkout@v4
77+
uses: actions/checkout@v3
6978
with:
7079
ref: gh-pages
7180

@@ -125,4 +134,5 @@ jobs:
125134
repo: context.repo.repo,
126135
body: commentBody,
127136
});
128-
}
137+
}
138+

0 commit comments

Comments
 (0)