Skip to content

Commit

Permalink
Merge pull request #13 from esg-epfl-apc/preview-action
Browse files Browse the repository at this point in the history
preview action
  • Loading branch information
francoismg authored Apr 23, 2024
2 parents a1bc5c2 + bf2c5c2 commit 523b866
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/preview-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/**
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "astrojsvis",
"description": "",
"version": "0.0.1",
"config": {
"prototype": "test"
},
"scripts": {
"build-preview": "mkdir -p preview; cp -r prototypes/${npm_package_config_prototype}/* preview/."
}
}
1 change: 1 addition & 0 deletions prototypes/test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!

0 comments on commit 523b866

Please sign in to comment.