Skip to content

Commit

Permalink
up to date demo actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuchet committed Oct 29, 2024
1 parent f7afc31 commit 37f0d55
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 25 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/clean-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Delete PR folder in gh-pages
on:
pull_request:
types: [closed]

permissions:
contents: write
pull-requests: write
statuses: write
checks: write
pages: write

jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: Checkout demo branch
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
with:
path: demo
ref: gh-pages

- name: Delete PR folder
run: |
rm -rf ./demo/${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit demo for gh-pages
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 #v1.4
with:
directory: "./demo"
github_token: ${{ secrets.GITHUB_TOKEN }}
message: "doc: cleanup demo"
branch: gh-pages
69 changes: 69 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Demo CI
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
statuses: write
checks: write
pages: write

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
name: Build and test
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3

- uses: pnpm/action-setup@v3
with:
version: 9

- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Setup access to qlik npm registry
uses: qlik-trial/qmfe-workflows/actions/npm-github-access@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install
working-directory: ./
run: pnpm install

- name: Build Demo
run: pnpm run test:demo

- name: Checkout demo branch
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
with:
path: demo
ref: gh-pages

- name: Add demo and commit it
# symlink creation : workaround to be able to use service worker on storybook both in local and via github pages deployment
run: |
cd demo && git rm -rf --ignore-unmatch ./main && cd ..
mkdir -p ./demo/main
cp -R storybook-static/* ./demo/main
cd demo && git add .
- name: Commit demo for gh-pages
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 #v1.4
with:
directory: "./demo"
github_token: ${{ secrets.GITHUB_TOKEN }}
message: "doc: update demo"
branch: gh-pages
51 changes: 26 additions & 25 deletions .github/workflows/pr-demo.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: PR Demo CI
on:
pull_request:
push:
branches: [master]

permissions:
contents: write
Expand All @@ -11,42 +9,37 @@ permissions:
checks: write
pages: write

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
name: Build demo on PR
environment: pull_request_unsafe
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7

- name: Use Node.js
uses: ./.github/actions/setup-node
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3

- name: cache for storybook
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 #v4.0.2
- uses: pnpm/action-setup@v3
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Setup access to qlik npm registry
uses: qlik-trial/qmfe-workflows/actions/npm-github-access@v2
with:
path: packages/*/node_modules
key: ${{ runner.os }}-storybook-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-storybook-
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install
working-directory: ./
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_READ_TOKEN }}
run: yarn install --frozen-lockfile
run: pnpm install

- name: Build
run: yarn test:demo
env:
STORYBOOK_FIGMA_ACCESS_TOKEN: ${{ secrets.STORYBOOK_FIGMA_ACCESS_TOKEN }}
- name: Build Demo
run: pnpm run test:demo

- name: Checkout demo branch
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
Expand All @@ -65,14 +58,22 @@ jobs:
- name: Commit demo for gh-pages
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 #v1.4
with:
directory: './demo'
directory: "./demo"
github_token: ${{ secrets.GITHUB_TOKEN }}
message: 'doc: update demo from ${{ github.event.number }}'
message: "doc: update demo from ${{ github.event.number }}"
branch: gh-pages

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: Storybook for this PR deployed on this

- name: Create comment
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa #v3.0.2
if: steps.fc.outputs.comment-id == ''
with:
issue-number: ${{ github.event.number }}
body: |
Storybook for this PR deployed on this [github page](https://crispy-disco-7v8q1pm.pages.github.io/${{ github.event.number }})
Storybook for this PR deployed on this [github page](https://legendary-chainsaw-woo3ynm.pages.github.io/${{ github.event.number }})

0 comments on commit 37f0d55

Please sign in to comment.