work on workflows #37
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
# Simple workflow for deploying static content to GitHub Pages | |
name: Deploy static content to Pages | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ['master'] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: 'pages' | |
cancel-in-progress: true | |
jobs: | |
benchmark: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Build site | |
env: | |
VITE_OFFLINE_VERSION: true | |
run: npm run build | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps | |
- name: Run Playwright tests | |
run: npx playwright test | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: benchmarks | |
path: benchmarks/ | |
retention-days: 30 | |
- name: Push benchmarks to repo | |
env: | |
VITE_OFFLINE_VERSION: true | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git add . | |
# Check for changes | |
if git diff-index --quiet HEAD --; then | |
# No changes | |
echo "No changes to commit" | |
else | |
# Changes detected | |
git commit -m "Add benchmarks" | |
git push origin master | |
fi | |
deploy: | |
needs: benchmark | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: ./package-lock.json | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
# Upload dist repository | |
path: './dist' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
- name: Push Offline Mode to Master | |
env: | |
VITE_OFFLINE_VERSION: true | |
run: | | |
npm run build | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git add . | |
# Check for changes | |
if git diff-index --quiet HEAD --; then | |
# No changes | |
echo "No changes to commit" | |
else | |
# Changes detected | |
git commit -m "Add dist folder" | |
git push origin master | |
fi |