Skip to content

Phoenix

Phoenix #480

Workflow file for this run

# Workflow for deploying static content to GitHub Pages using GitHub Actions
# it will also run linting and unit tests before deploying
# the BYOB package is used to update and create custom status badges
name: Lint, Test & Deploy
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Runs on pushes targeting the main branch
push:
branches: ['main']
# Ignores changes in the .md, .env.example and .gitignore files
paths-ignore:
- '**/*.env.example'
- '.gitignore'
pull_request:
branches: ['main']
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- '**/*.env.example'
- '.gitignore'
env:
CI: true
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages & create status badges
permissions:
contents: write
pages: write
id-token: write
jobs:
setup:
if: '! github.event.pull_request.draft'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache npm modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
run: npm ci
lint:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Update lint Badge
uses: RubbaBoy/BYOB@v1.3.0
if: ${{ always() }}
with:
name: lint
status: ${{ job.status }}
color: ${{ job.status == 'success' && '31A802' || job.status == 'failure' && 'D10007' || 'E0A607' }}
label: 'Lint Status'
github_token: ${{ secrets.GITHUB_TOKEN }}
unit-test:
name: Unit Test
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test-unit
- name: Update test Badge
uses: RubbaBoy/BYOB@v1.3.0
if: ${{ always() }}
with:
name: unit-test
status: ${{ job.status }}
color: ${{ job.status == 'success' && '31A802' || job.status == 'failure' && 'D10007' || 'E0A607' }}
label: 'Unit Test Status'
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Build Vite
run: npm run build
- name: Update build Badge
uses: RubbaBoy/BYOB@v1.3.0
if: ${{ always() }}
with:
name: build
status: ${{ job.status }}
color: ${{ job.status == 'success' && '31A802' || job.status == 'failure' && 'D10007' || 'E0A607' }}
label: 'Build Status'
github_token: ${{ secrets.GITHUB_TOKEN }}
e2e:
name: E2E Tests
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cypress run
uses: cypress-io/github-action@v6
with:
build: npm run build
start: npm run dev
wait-on: 'http://127.0.0.1:5173/'
wait-on-timeout: 60
browser: chrome # only run in chrome to save time
- name: Update e2e Badge
uses: RubbaBoy/BYOB@v1.3.0
if: ${{ always() }}
with:
name: e2e
status: ${{ job.status }}
color: ${{ job.status == 'success' && '31A802' || job.status == 'failure' && 'D10007' || 'E0A607' }}
label: 'E2E Status'
github_token: ${{ secrets.GITHUB_TOKEN }}
# only runs if the previous jobs are successful and the push event is targeting the main branch
deploy:
needs: [setup, lint, unit-test, build, e2e]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# Allow one concurrent deployment
concurrency:
group: 'deploy-${{ github.ref }}'
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install
run: npm ci
- name: Build Vite
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload build file
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Update deploy Badge
uses: RubbaBoy/BYOB@v1.3.0
if: ${{ always() }}
with:
name: deploy
status: ${{ job.status }}
color: ${{ job.status == 'success' && '31A802' || job.status == 'failure' && 'D10007' || 'E0A607' }}
label: 'Deployment Status'
github_token: ${{ secrets.GITHUB_TOKEN }}