Skip to content

Better echo

Better echo #238

# Summary:
# Test the GitHub Action using an integration test.
# Makes sure the GitHub Action works properly when running on a clean machine, without building anything (integration test).
#
# See https://github.com/actions/checkout https://github.com/actions/checkout/releases/tag/v3
name: 'GitHub Action integration test'
on:
pull_request:
push:
jobs:
run-integration-test1:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn # Install all dependencies
- uses: ./
id: store-variables
with:
variables: |
URL=https://github.com
# Next step: verify that the variable has been saved in the ENV.
- run: |
if [ -z "$URL" ]; then
echo "Error: github-action-store-variable lib did not save 'URL' to ENV as expected. The library is not working as intended."
exit 1
fi
echo "Exported variable URL is: $URL"
env:
URL: ${{ env.URL }}
run-integration-test2:
runs-on: ubuntu-22.04
needs: run-integration-test1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn # Install all dependencies
- uses: ./
with:
variables: |
URL
SECOND_URL=https://github.com/UnlyEd
# Next step: verify that both URL and SECOND_URL were propagated.
- run: |
if [ -z "$URL" ]; then
echo "Error: github-action-store-variable lib did not propagate 'URL' to the environment as expected. The library is not working as intended."
exit 1
fi
if [ -z "$SECOND_URL" ]; then
echo "Error: github-action-store-variable lib did not save 'SECOND_URL' to ENV as expected. The library is not working as intended."
exit 1
fi
echo "Found from previous job, URL is: $URL"
echo "Exported variable SECOND_URL is: $SECOND_URL"
env:
URL: ${{ env.URL }}
SECOND_URL: ${{ env.SECOND_URL }}
run-integration-test3:
runs-on: ubuntu-22.04
needs: run-integration-test2
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn # Install all dependencies
- uses: ./
with:
variables: |
URL
SECOND_URL
# Next step: verify that URL and SECOND_URL are available.
- run: |
if [ -z "$URL" ]; then
echo "Error: github-action-store-variable lib did not propagate 'URL' to the environment as expected. The library is not working as intended."
exit 1
fi
if [ -z "$SECOND_URL" ]; then
echo "Error: github-action-store-variable lib did not propagate 'SECOND_URL' to the environment as expected. The library is not working as intended."
exit 1
fi
echo "Found from previous job, URL is: $URL"
echo "Found from previous job, SECOND_URL is: $SECOND_URL"
env:
URL: ${{ env.URL }}
SECOND_URL: ${{ env.SECOND_URL }}
should-not-fail-on-retrieving-UNKNOWN_VAR:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn # Install all dependencies
- uses: ./
with:
variables: |
UNKNOWN_VAR
failIfNotFound: false # Default is false, so missing UNKNOWN_VAR is allowed.