02_Select Environment at run-time #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This GitHub Actions workflow is designed to execute API tests developed using Playwright 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 Playwright 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 Playwright API tests on selected environment | |
- name: Run Playwright API tests on selected environment | |
run: npm run tests:${{ github.event.inputs.environment }} | |
# Step 5: Upload Playwright test report as an artifact | |
- name: Upload Reports | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: API Tests Report | |
path: playwright-report/ | |
retention-days: 30 |