Skip to content

Create GHA extract shell scripts action #27

Create GHA extract shell scripts action

Create GHA extract shell scripts action #27

---
name: Integration Tests
on:
pull_request:
paths:
- "action.yaml"
- "gha_extract_shell_scripts.py"
- ".github/workflows/integration-tests.yaml"
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./
id: gha-extract-shell-scripts
# Define expected output as as separate step to avoid the expected value being
# included in the test value.
- name: Define expected
id: expected
run: |
{
echo "content<<EOF"
echo "${expected:?}"
echo "EOF"
} | tee -a "$GITHUB_OUTPUT"
env:
expected: |
#!/usr/bin/env bash
set -e
# shellcheck disable=SC2034
workflow_file='integration-tests.yaml'
# ---
output_file="workflow_scripts/:env.workflow_file:/job=Test/step=Test_extracted.sh"
expected="$(expected="$(sed "s/'/'\\\\''/g" <<<"\$expected")" envsubst '\$expected' <<<"\$expected")"
if [[ ! -f "$output_file" ]]; then
find .
exit 1
fi
diff --color=always "$output_file" <(echo ":steps.expected.outputs.content:")
- name: Test extracted
run: |
output_file="workflow_scripts/${{ env.workflow_file }}/job=Test/step=Test_extracted.sh"
if [[ ! -f "$output_file" ]]; then
find .
exit 1
fi
diff --color=always "$output_file" <(echo "${{ steps.expected.outputs.content }}")
env:
workflow_file: integration-tests.yaml