Skip to content

Test Action

Test Action #21

Workflow file for this run

name: Test Action
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
test_name:
description: 'Test name input'
required: true
type: string
test_number:
description: 'Test number input'
required: false
type: number
jobs:
test-push-pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Run action (no inputs expected)
uses: ./
id: print_inputs
- name: Check output (no inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"This is not a workflow_dispatch event. No inputs expected."* ]]; then
echo "Test passed: No inputs were found, as expected for push/pull_request events"
else
echo "Test failed: Unexpected output for push/pull_request events"
exit 1
fi
test-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Run action (inputs expected)
uses: ./
id: print_inputs
with:
add_to_summary: true
- name: Check output (inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"test_name"* && "${{ steps.print_inputs.outputs.output }}" == *"test_number"* ]]; then
echo "Test passed: Inputs were printed correctly for workflow_dispatch event"
else
echo "Test failed: Inputs were not printed as expected for workflow_dispatch event"
exit 1
fi
test-env-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run action (with env vars)
uses: ./
id: print_inputs_and_env
with:
print_env_vars: 'true'
- name: Check output (env vars)
run: |
echo "Action output:"
echo "${{ steps.print_inputs_and_env.outputs.output }}"
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* && "${{ steps.print_inputs_and_env.outputs.output }}" == *"GITHUB_"* ]]; then
echo "Test passed: Environment variables were printed correctly"
else
echo "Test failed: Environment variables were not printed as expected"
exit 1
fi