Skip to content

[WiP] Combined GH Action for Testing and Deployment #16

[WiP] Combined GH Action for Testing and Deployment

[WiP] Combined GH Action for Testing and Deployment #16

Workflow file for this run

name: End-to-End Tests with Deployment
on: [push, pull_request]
jobs:
build_deploy_and_test:
runs-on: ubuntu-latest
strategy:
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
matrix:
browser: [chrome, firefox]
containers: [1, 2] # Uses 2 parallel instances
steps:
# Step 1: Checkout code
- uses: actions/checkout@v3
# Step 2: Setup Node
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
# Step 3: Build
- run: npm ci && npm run build
# Step 4: Deploy to Firebase and capture the preview link
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GSE_ROAR_ADMIN }}'
projectId: gse-roar-admin
target: staging
# Assuming the Firebase deploy action sets the preview URL in the deployment status
# If the URL is not set automatically, you will need to adjust this step to capture it correctly
- name: Set PR Link as Env Variable
run: |
echo "FIREBASE_DEPLOY_URL=${{ steps.firebase_deploy.outputs.deploy_url }}" >> $GITHUB_ENV
echo "Captured URL: ${{ steps.firebase_deploy.outputs.deploy_url }}"
# Step 5: Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
build: echo "Build step already completed"
start: echo "App already deployed to Firebase"
wait-on: ${{ env.FIREBASE_DEPLOY_URL }}
wait-on-timeout: 120
record: true
parallel: true
spec: cypress/e2e/participant/checkLegalDoc.cy.js
env:
CYPRESS_BASE_URL: ${{ env.FIREBASE_DEPLOY_URL }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}