Skip to content

2024 new data

2024 new data #403

name: 'UI: tests & dev deploy'
on:
pull_request:
branches:
- main
push:
branches-ignore:
- main
paths:
- 'ui/**'
- 'air-pollutant-map/**'
- '.github/workflows/ui-test-deploy-dev.yml'
env:
AZURE_WEBAPP_NAME: syke-prtr-d-web
AZURE_WEBAPP_PACKAGE_PATH: 'ui/build' # path to web resources
NODE_VERSION: '20.10.0'
jobs:
test:
name: Cypress tests (UI)
if: ${{ github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: npm ci
run: npm ci
working-directory: ui
- name: Cypress tests
run: |
npm start & npm run wait-on -- http://localhost:3000
npm run cypress:run
working-directory: ui
test-build-deploy-dev:
name: Test, Build and Deploy (dev)
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: azure/login@v1
with:
creds: ${{ secrets.DEV_AZURE_CREDENTIALS }}
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- name: npm ci
run: npm ci
working-directory: ui
- name: Cypress tests
run: |
npm start & npm run wait-on -- http://localhost:3000
npm run cypress:run
working-directory: ui
- name: npm build
run: npm run build
working-directory: ui
- name: add process.json
run: |
echo '{ script: "serve", env: { PM2_SERVE_SPA: "true", PM2_SERVE_HOMEPAGE: "/index.html" } }' >> build/process.json
working-directory: ui
- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: logout
run: |
az logout