Skip to content

Commit

Permalink
ci/cd workflows: gh-pages & pr-preview; rm manual deploy info
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed Aug 31, 2024
1 parent f91b610 commit ea95f2b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 341 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main

permissions:
contents: write

jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-20.04
if: github.repository == 'aiidateam/aiida-explorer'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Set vite base path variable
run: echo "VITE_BASE_PATH=/aiida-explorer/" >> $GITHUB_ENV

- name: Install and build project
run: |
npm install
npm run build
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./dist
# for pr-preview:
clean-exclude: pr-preview/
force: false
41 changes: 41 additions & 0 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy PR previews

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed

concurrency: preview-${{ github.ref }}

jobs:
deploy-preview:
runs-on: ubuntu-20.04
if: github.repository == 'aiidateam/aiida-explorer'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Set vite base path variable
env:
PR_NUMBER: ${{ github.event.number }}
run: echo "VITE_BASE_PATH=/aiida-explorer/pr-preview/pr-${PR_NUMBER}" >> $GITHUB_ENV

- name: Install and Build
if: github.event.action != 'closed'
run: |
npm install
npm run build
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./dist/
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The initial version of this tool was created by Sharan Poojari during Google Sum
This repository contains

1. the `AiidaExplorer` component (library), which is also published to `npm`; and
2. a demo page illustrating the usage, which is deployed to github pages.
2. a demo page illustrating the usage, which is deployed to github pages (https://aiidateam.github.io/aiida-explorer/).

## Installation and usage

Expand Down Expand Up @@ -74,6 +74,8 @@ git push --follow-tags

### Deploying the demo page to github-pages

```
npm run deploy
```
The demo page is deployed to Github pages automatically from the `main` branch.

Additionally, any pull request gets deployed in it's own subpath as well.

Manual deployment to Github pages should not be done, as that might break any PR previews.
Loading

0 comments on commit ea95f2b

Please sign in to comment.