Skip to content

Commit

Permalink
preview based on test-webpage-build
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Sep 16, 2023
1 parent 042374d commit 5ba6825
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 79 deletions.
11 changes: 8 additions & 3 deletions .github/actions/generate-metadata/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,35 @@ inputs:
description: GitHub token
required: true
type: string
cache:
description: use caching or not
required: true
type: boolean

runs:
using: composite
steps:
- name: Restore cached Plugins
if: inputs.cache == true
id: cache-plugins-restore
uses: actions/cache/restore@v3
with:
path: plugins_metadata.json
key: plugins_metadata
- name: fetch metadata
if: steps.cache-plugins-restore.outputs.cache-hit != 'true'
if: steps.cache-plugins-restore.outputs.cache-hit != 'true' || inputs.cache
id: fetch_metadata
env:
GITHUB_TOKEN: ${{ inputs.gh_token }}
run: aiida-registry fetch
shell: bash
- name: Check plugins installation
if: steps.cache-plugins-restore.outputs.cache-hit != 'true'
if: steps.cache-plugins-restore.outputs.cache-hit != 'true' || inputs.cache
# This step will attach plugin installation inforamtion to the metadata, e.g. if the plugin can be installed or not
run: aiida-registry test-install
shell: bash
- name: Cache plugins metadata
if: steps.cache-plugins-restore.outputs.cache-hit != 'true'
if: steps.cache-plugins-restore.outputs.cache-hit != 'true' || inputs.cache
id: cache-plugins-save
uses: actions/cache/save@v3
with:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,62 @@ jobs:

- name: Generate metadata
uses: ./.github/actions/generate-metadata
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
cache: true

- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install npm dependencies and build
run: |
echo $VITE_PR_PREVIEW_PATH
npm install
npm run build
working-directory: ./aiida-registry-app

preview:
needs: [test-webpage-build]
runs-on: ubuntu-latest
strategy:
fail-fast: false
timeout-minutes: 60
env:
COMMIT_AUTHOR: Deploy Action
COMMIT_AUTHOR_EMAIL: action@github.com
VITE_PR_PREVIEW_PATH: "/aiida-registry/pr-preview/pr-${{ github.event.number }}/"

# This is a CI job that checks if the webpage can be built
# We use the plugins metadata from caching since we don't want to
# fetch it twice and it is not essential for this job to have
# the latest generated metadata
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v3
- name: Create dev environment
uses: ./.github/actions/create-dev-env

- name: Generate metadata
uses: ./.github/actions/generate-metadata
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
cache: false

- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install npm dependencies and build
run: |
echo $VITE_PR_PREVIEW_PATH
npm install
npm run build
working-directory: ./aiida-registry-app

- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./aiida-registry-app/dist
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
custom-url:
13 changes: 5 additions & 8 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ jobs:
- name: Create dev environment
uses: ./.github/actions/create-dev-env

- name: fetch metadata
id: fetch_metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: aiida-registry fetch
- name: Check plugins installation
# This step will attach plugin installation inforamtion to the metadata, e.g. if the plugin can be installed or not
run: aiida-registry test-install
- name: Generate metadata
uses: ./.github/actions/generate-metadata
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
cache: false

- name: Create commit comment
if: steps.fetch_metadata.outputs.error
Expand Down
68 changes: 0 additions & 68 deletions .github/workflows/preview.yml

This file was deleted.

0 comments on commit 5ba6825

Please sign in to comment.