Skip to content

Commit

Permalink
Also run build and test on PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hanna committed Jan 16, 2024
1 parent d419672 commit fa0fe99
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,66 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:

runs-on: ubuntu-latest
permissions:
contents: write
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 20

- name: Install and Build
- name: Build
run: |
npm install
npm ci
npm run build
env:
MODE: production

- name: Test
run: npm test

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v2
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
path: './app'
name: 'build'
path: './'

deploy:
needs: build-and-test

runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
runs-on: ubuntu-latest

needs: build-and-test
if: github.ref == 'refs/heads/main'

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: 'build'

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: './app'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4

0 comments on commit fa0fe99

Please sign in to comment.