Jsvis prototype #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy PR previews | |
concurrency: preview-${{ github.ref }} | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- closed | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- run: npm i && npm run build-preview | |
if: github.event.action != 'closed' | |
- id: deploy_preview | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
source-dir: preview | |
preview-branch: gh-pages | |
umbrella-dir: pr-preview | |
action: auto | |
custom-url: | |
- name: Add link to index | |
if: github.event.action != 'closed' | |
run: | | |
git checkout gh-pages | |
git pull | |
if ! grep ${{ steps.deploy_preview.outputs.deployment-url }} index.html; then | |
sed -i '\|<div id="previews">|a <a href="${{ steps.deploy_preview.outputs.deployment-url }}">Preview PR#${{ github.event.pull_request.number }}</a><br>' index.html | |
git add index.html | |
git commit -m 'Added preview link' | |
git push | |
fi | |
- name: Remove link from index | |
if: github.event.action == 'closed' | |
run: | | |
git checkout gh-pages | |
git pull | |
if grep ${{ steps.deploy_preview.outputs.deployment-url }} index.html; then | |
sed -i '\|${{ steps.deploy_preview.outputs.deployment-url }}|d' index.html | |
git add index.html | |
git commit -m 'Added preview link' | |
git push | |
fi |