Skip to content

Commit

Permalink
Create test-and-deploy.yml workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
drauf authored Aug 15, 2023
1 parent a847f31 commit b17f786
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Test and deploy to Pages

on:
# Runs on pushes targeting the default branch and pull requests
push:
branches: ["main"]
pull_request:

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
test:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:next-jammy

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

- name: Setup Node 20
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --frozen-lockfile --immutable
- run: yarn lint
- run: yarn test

- name: Install Playwright browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: HOME=/root yarn playwright test
- name: Upload Playwright report
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- name: Build static page for deployment
run: yarn predeploy
- name: Upload artifact for deployment
uses: actions/upload-pages-artifact@v2
with:
path: ./build

deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref_name == "main"

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

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

0 comments on commit b17f786

Please sign in to comment.