Fix web build #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
jobs: | |
test: | |
name: test 🧪 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- name: Setup node | |
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm run test --workspace @braingoat/compiler | |
build: | |
name: build ⚙️ | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- name: Setup node | |
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build react-app | |
run: | | |
npm run build --workspace @braingoat/compiler | |
npm run build --workspace @braingoat/web -- --base=/braingoat/ | |
- name: Upload build | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 | |
with: | |
name: react-build | |
path: packages/web/dist/ | |
deploy-page: | |
name: deploy web 🚀 | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: ${{ github.ref == 'refs/heads/main' }} | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- name: Download build | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a | |
with: | |
name: react-build | |
path: dist/ | |
- name: Setup Pages | |
uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@84bb4cd4b733d5c320c9c9cfbc354937524f4d64 | |
with: | |
# Upload dist repository | |
path: "./dist" | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@13b55b33dd8996121833dbc1db458c793a334630 | |
deploy-npm: | |
name: deploy npm 🚀 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
concurrency: | |
group: "npm" | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 | |
with: | |
node-version: "20" | |
registry-url: 'https://npm.pkg.github.com' | |
scope: '@wolflu05' | |
- run: npm ci | |
- run: npm build | |
- id: check | |
run: | | |
version=$(node -e "const fs = require('fs'); const path = require('path'); const p = path.resolve('packages', 'compiler', 'package.json'); const currentPackageJSON = fs.readFileSync(p , {encoding: 'utf-8'}); fs.writeFileSync(p, currentPackageJSON.replace('@braingoat/compiler', '@wolflu05/braingoat'), {encoding: 'utf-8'}); console.log(JSON.parse(currentPackageJSON).version)") | |
if [[ $(npm search wolflu05/braingoat@$version) == *"No matches"* ]]; then | |
echo "publish=true" >> $GITHUB_OUTPUT | |
fi | |
- run: npm publish -w @wolflu05/braingoat | |
if: ${{ steps.check.outputs.publish }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |