Skip to content

Commit

Permalink
ci: add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhooks committed Jan 17, 2023
1 parent 97bbb39 commit a90daf6
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 191 deletions.
33 changes: 33 additions & 0 deletions .github/actions/node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Setup yarn

runs:
using: "composite"
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Install specific Yarn version
shell: bash
run: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.22.19
echo 'export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"' >> $GITHUB_PATH
- name: Get yarn cache directory path
id: yarn-cache-dir-path
shell: bash
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache node_modules
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Packages
shell: bash
run: yarn install --frozen-lockfile && yarn --cwd ./example install --frozen-lockfile
26 changes: 26 additions & 0 deletions .github/workflows/build-pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build package

on: workflow_call

jobs:
build-pkg:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js and Yarn
uses: ./.github/actions/node

# Not currently attempting to build WASM modules on CI

- name: Build package
shell: bash
run: yarn build:rollup

- name: Archive build artifact
uses: actions/upload-artifact@v3
with:
name: pkg-build-${{ github.run_id }}
path: |
example/public
34 changes: 34 additions & 0 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build website

on:
workflow_call:
inputs:
environment:
required: true
type: string

jobs:
website:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js and Yarn
uses: ./.github/actions/node

- name: Download the build artifact
uses: actions/download-artifact@v3
with:
name: pkg-build-${{ github.run_id }}

- name: Build website
shell: bash
run: yarn website:build

# This action uploads an artifact named `github-pages` which will be used by actions/deploy-pages
- name: Upload artifact
if: ${{ inputs.environment == 'production' }}
uses: actions/upload-pages-artifact@v1
with:
path: ./example/dist
18 changes: 18 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: on pull request

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches:
- "**/*"

jobs:
build:
uses: ./.github/workflows/build-pkg.yml

website:
needs: build
uses: ./.github/workflows/build-website.yml
with:
environment: development
49 changes: 49 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: On push

on:
# Runs on pushes targeting the main branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/build-pkg.yml

website:
needs: build
uses: ./.github/workflows/build-website.yml
with:
environment: production

pages:
# Only deploy if the string '(website)' is in the commit message. NOTE not a RegExp
if: "contains(github.event.head_commit.message, '(website)')"

# Add a dependency to the build job
needs: website

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
contents: read
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,19 @@
},
"typescript.autoClosingTags": false,
"typescript.suggest.completeJSDocs": false,
"typescript.disableAutomaticTypeAcquisition": true
"typescript.disableAutomaticTypeAcquisition": true,
"cSpell.words": [
"audioworklet",
"emscripten"
],
"cSpell.ignorePaths": [
"**/package-lock.json",
"**/build/**",
"**/dist/**",
"**/node_modules/**",
"**/vscode-extension/**",
"**/.git/objects/**",
"./vscode/**"
],
"typescript.tsdk": "node_modules/typescript/lib"
}
8 changes: 6 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "daisysp-wasm-example-website",
"name": "daisysp-wasm-example",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
},
"devDependencies": {
"vite": "4.0.4"
},
"type": "module"
}
Loading

0 comments on commit a90daf6

Please sign in to comment.