Skip to content

Test Action

Test Action #16

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
- name: Check GitHub Summary
run: |
echo "Debug Info:"
echo "${{ steps.run_action.outputs.debug_info }}"
echo "Summary Content from output:"
echo "${{ steps.run_action.outputs.summary_content }}"
echo "Summary Content from file (if exists):"
if [ -f summary_content.txt ]; then
cat summary_content.txt
else
echo "summary_content.txt does not exist"
fi
summary_content="${{ steps.run_action.outputs.summary_content }}"
if [[ "$summary_content" == *"<details>"* ]] && [[ "$summary_content" == *"test_name"* ]] && [[ "$summary_content" == *"test_number"* ]]; then
echo "Test passed: Inputs were added to GitHub Summary in collapsible format"
else
echo "Test failed: Inputs were not added to GitHub Summary as expected"
echo "Summary content:"
echo "$summary_content"
echo "GitHub Step Summary content:"
if [ -f "$GITHUB_STEP_SUMMARY" ]; then
cat $GITHUB_STEP_SUMMARY
else
echo "$GITHUB_STEP_SUMMARY file does not exist"
fi
echo "Workflow inputs:"
echo "test_name: ${{ github.event.inputs.test_name }}"
echo "test_number: ${{ github.event.inputs.test_number }}"
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