Workflow Input Triggers
In this documentation, we'll explore the "Workflow Input Triggers" GitHub Actions workflow. This workflow allows you to manually trigger its execution and provides input parameters to customize its behavior.
Workflow Trigger
The workflow is triggered manually using the "workflow_dispatch" event, which allows users to input specific parameters when starting the workflow execution.
Workflow Inputs
The following inputs can be provided when triggering this workflow:
node-version
: Specifies the Node.js version to use. It is optional and defaults to '14.x' if not provided.npm-install-command
: Specifies the npm install command. This input is required.run-playwright
: A boolean flag indicating whether Playwright testing should be enabled. It is optional and defaults to true.upload-artifact
: A boolean flag indicating whether artifact upload should be enabled. It is optional and defaults to true.
Workflow Execution
To manually trigger this workflow and customize its behavior, you can use the GitHub Actions interface:
Navigate to your repository on GitHub.
Click on the "Actions" tab.
In the left sidebar, you will see the name of the workflow: "Workflow Input Triggers." Click on it.
Click the "Run workflow" button.
Customize the workflow by providing input values:
- Set the
node-version
input if you want to use a specific Node.js version. - Specify the required
npm-install-command
. - Toggle the
run-playwright
andupload-artifact
options as needed.
- Set the
Click the "Run workflow" button to start the workflow with your custom inputs.
Workflow Steps
The workflow consists of the following steps:
Checkout Code:
- Action:
actions/checkout@v3
- Description: This step checks out the repository code.
- Action:
Setup Node.js:
- Action:
actions/setup-node@v3
- Description: Sets up the Node.js environment based on the specified
node-version
input or the default '14.x'.
- Action:
Install Dependencies:
- Action: Runs the npm command specified in the
npm-install-command
input, which is required for building the application.
- Action: Runs the npm command specified in the
Install Playwright Browsers:
- Action:
npx playwright install --with-deps
- Description: Installs Playwright browsers, but only if the
run-playwright
input is set to true.
- Action:
Run Playwright Tests:
- Action:
npx playwright test
- Description: Runs Playwright tests, but only if
run-playwright
is set to true. It also sets environment variablesUSERNAME
andPASSWORD
using the configured secrets.
- Action:
Upload Artifact:
- Action:
actions/upload-artifact@v3
- Description: Uploads the 'playwright-report/' directory as an artifact, but only if the
upload-artifact
input is set to true. The artifact will be retained for 30 days.
- Action:
full yaml file
name: workflow input triggers
on:
workflow_dispatch:
inputs:
node-version:
description: 'Node.js version'
required: false
default: '14.x' # Default Node.js version if not provided
npm-install-command:
description: 'npm install command'
required: true
run-playwright:
description: 'Enable Playwright testing'
required: false
default: 'true' # Enable Playwright testing by default
upload-artifact:
description: 'Enable artifact upload'
required: false
default: 'true' # Enable artifact upload by default
jobs:
run-workflow-triggers:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
- name: Install Dependencies
run: npm ${{ inputs.npm-install-command }}
- name: Install Playwright Browsers
if: ${{ inputs.run-playwright == 'true' }}
run: npx playwright install --with-deps
- name: Run Playwright Tests
if: ${{ inputs.run-playwright == 'true' }}
run: npx playwright test
- name: Upload Artifact
if: ${{ inputs.upload-artifact == 'true' }}
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: playwright-report/