Skip to content

02_Select Environment at run-time #1

02_Select Environment at run-time

02_Select Environment at run-time #1

# This GitHub Actions workflow is designed to execute API tests developed using Cypress and Javascript.
# It supports manual trigger and handles inputs for environment selection.
name: 02_Select Environment at run-time
on:
# Manual Trigger with environment selection input
workflow_dispatch:
inputs:
environment:
description: 'Select environment (DEV | PRE-PROD | PROD)'
options:
- 'DEV'
- 'PRE-PROD'
- 'PROD'
required: true
default: 'PROD'
type: choice
jobs:
# Job for running Cypress tests
api_tests_env_selected:
# Set a maximum timeout for the job
timeout-minutes: 30
# Define the machine on which tests will execute
runs-on: ubuntu-latest
steps:
# Step 1: Checking out the code from the GitHub repository to the machine (ubuntu-latest)
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Installing Node.js
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
# Step 3: Install project dependencies
- name: Install dependencies
run: npm ci
# Step 4: Run Cypress API tests on selected environment
- name: Run Cypress API tests on selected environment
run: npm run tests:${{ github.event.inputs.environment }}
# Step 5: Upload Cypress test report as an artifact
- name: Upload Reports
uses: actions/upload-artifact@v3
if: always()
with:
name: API Tests Report
path: cypress/reports
retention-days: 30