Update README.md (#71) #244
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Testing the action | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
# Declare default GITHUB_TOKEN permissions as read only. | |
permissions: read-all | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- name: Run dev with error cases (should fail) | |
run: | | |
echo "Testing with no GITHUB_REF set" | |
GITHUB_REF="" node main.js | |
# shellcheck disable=SC2181 | |
if [ $? -ne 1 ]; then echo "Expected failure on no GITHUB_REF set"; fi | |
- name: Run dev with error cases (should fail) | |
if: always() | |
run: | | |
echo "Testing with invalid GITHUB_REF" | |
GITHUB_REF=origin/refs/tag/v1 node main.js | |
# shellcheck disable=SC2181 | |
if [ $? -ne 1 ]; then echo "Expected failure on invalid ref"; fi | |
- name: Run dev with different error cases (should fail) | |
if: always() | |
run: | | |
echo "Testing with valid GITHUB_REF" | |
GITHUB_REF=refs/tag/v1 node main.js | |
# shellcheck disable=SC2181 | |
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to tag"; fi | |
- name: Run dev | |
id: tag_dev | |
run: | | |
echo "Testing with valid GITHUB_REF" | |
GITHUB_REF=refs/heads/main node main.js | |
# shellcheck disable=SC2181 | |
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to branch"; fi | |
echo "Testing with valid GITHUB_REF" | |
GITHUB_REF=refs/tags/v1.0.0 node main.js | |
# shellcheck disable=SC2181 | |
if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref with minor version"; fi | |
- name: Test dev | |
if: always() | |
run: | | |
test "v1.0.0" = "${{steps.tag_dev.outputs.tag}}" | |
- name: Run dev with strip v | |
if: always() | |
id: tag_dev_strip_v | |
run: | | |
GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="true" node main.js | |
- name: Test dev with strip v | |
if: always() | |
run: | | |
test "1.0.0" = "${{steps.tag_dev_strip_v.outputs.tag}}" | |
- name: Run prod | |
id: tag_prod | |
if: startsWith(github.ref, 'refs/tags') == true | |
uses: ./ | |
- name: Test prod | |
if: startsWith(github.ref, 'refs/tags') == true | |
run: | | |
test -n "${{steps.tag_prod.outputs.tag}}" | |
- name: Run dev with no strip_v and a default | |
if: always() | |
id: tag_dev_no_strip_v_default | |
run: | | |
GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="false" INPUT_DEFAULT="v0.0.0" node main.js | |
- name: Test dev with no strip_v and default value | |
if: always() | |
run: | | |
test "v1.0.0" = "${{steps.tag_dev_no_strip_v_default.outputs.tag}}" | |
- name: Run dev with no tag, no strip_v and a default and not a tag | |
if: always() | |
id: no_tag_dev_no_strip_v_default | |
run: | | |
GITHUB_REF=random_branch INPUT_STRIP_V="false" INPUT_DEFAULT="v0.99.0" node main.js | |
- name: Test dev with no tag, no strip_v and default value | |
if: always() | |
run: | | |
test "v0.99.0" = "${{steps.no_tag_dev_no_strip_v_default.outputs.tag}}" | |