Skip to content

goatscript #1: run-with-summary #2

goatscript #1: run-with-summary

goatscript #1: run-with-summary #2

# Test the scripts.
name: Run with Summary
on:
pull_request:
branches:
- main
# Settings for run-with-summary script.
env:
FILE: report-${{ github.run_id }}.md
SUMMARY: yes
DEBUG: yes
jobs:
run-with-summary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: run-with-summary
env:
SUCCESS: "Test Command Succeeded :white_check_mark:"
ERROR: "Test Command Failed! :x:"
run: |
set -o pipefail
set +e
./src/run-with-summary ls -la
exit_code=$?
cat $FILE >> $GITHUB_STEP_SUMMARY
exit $exit_code
run-with-summary-fail:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: run-with-summary failure
env:
SUCCESS: "Ping Succeeded :white_check_mark:"
ERROR: "Ping Failed, as expected :x:"
run: |
set -o pipefail
set +e
./src/run-with-summary ping w3.org -c1
exit_code=$?
cat $FILE >> $GITHUB_STEP_SUMMARY
echo "EXIT_CODE=$exit_code" >> $GITHUB_ENV
- name: exit
run: |
if [ "$EXIT_CODE" == "0" ]; then
echo "Script was expected to fail. Something is wrong."
exit 1
else
echo "Exit code is not 0, as expected."
fi