Skip to content

Commit

Permalink
fixed preview workflow (TuringLang#463)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
shravanngoswamii authored and Shravan Goswami committed May 29, 2024
1 parent d3c0e0d commit 8a704f8
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR Preview Workflow

on:
pull_request:
pull_request_target:
types:
- opened
- synchronize
Expand All @@ -13,7 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Julia
uses: julia-actions/setup-julia@v2
Expand Down Expand Up @@ -46,26 +48,33 @@ jobs:
_freeze/
key: ${{ runner.os }}-primes-${{ github.run_id }}

- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages

- name: Deploy Preview to GitHub Pages
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
mkdir -p gh-pages/${PREVIEW_DIR}
cp -r _site/* gh-pages/${PREVIEW_DIR}
cd gh-pages
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Deploy preview for PR ${PR_NUMBER}"
git push
env:
GH_PAT: ${{ secrets.GH_PAT }}

delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
ref: gh-pages

Expand Down Expand Up @@ -125,4 +134,5 @@ jobs:
repo: context.repo.repo,
body: commentBody,
});
}
}

0 comments on commit 8a704f8

Please sign in to comment.