4" displays #10
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Check out the code | |
- name: Check out code | |
uses: actions/checkout@v3 | |
# 2. Use Node | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
# 3. Install dependencies & run build.js in the main repo (FrameOS/cases) | |
- name: Install dependencies (FrameOS/cases) | |
run: npm install | |
- name: Run build script (FrameOS/cases) | |
run: node build.js | |
# 4. Clone the openscad-playground repo | |
- name: Clone openscad-playground | |
run: git clone https://github.com/FrameOS/openscad-playground.git | |
# 5. Build openscad-playground | |
- name: Build openscad-playground | |
run: | | |
cp dist/cases.json openscad-playground/src/cases.json | |
cd openscad-playground | |
make public | |
npm install | |
NODE_ENV=production npm run build | |
# 6. Deploy dist to openscad-playground-deploy | |
- name: Deploy dist to openscad-playground-deploy | |
run: | | |
# Clone deploy repo with shallow depth | |
git clone --depth=1 \ | |
https://${{ secrets.CASES_DEPLOY_TOKEN }}@github.com/FrameOS/openscad-playground-deploy.git \ | |
deploy | |
# Remove all existing files in the deploy repo (except .git) | |
rm -rf deploy/* | |
# Copy new dist files from openscad-playground | |
cp -r openscad-playground/dist/* deploy | |
# Commit and push changes | |
cd deploy | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
# If there are no changes, this will fail; so we use '|| echo' to prevent an error | |
git commit -m "Deploy" || echo "No changes to commit" | |
git push origin main |