@@ -57,7 +57,12 @@ teardown() {
5757 rm -rf " ${FAKE_LOCAL_REPOSITORY} "
5858 rm -rf " ${FAKE_REMOTE} "
5959 rm -rf " ${FAKE_TEMP_LOCAL_REPOSITORY} "
60- rm " ${GITHUB_OUTPUT} "
60+
61+ if [ -z ${GITHUB_OUTPUT+x} ]; then
62+ echo " GITHUB_OUTPUT is not set"
63+ else
64+ rm " ${GITHUB_OUTPUT} "
65+ fi
6166}
6267
6368# Create a fake remote repository which tests can push against
@@ -997,3 +1002,42 @@ cat_github_output() {
9971002 refute_line --partial " new-file-2.txt"
9981003 refute_line --partial " new-file-3.txt"
9991004}
1005+
1006+
1007+ @test " It uses old set-output syntax if GITHUB_OUTPUT environment is not available when changes are committed" {
1008+ unset GITHUB_OUTPUT
1009+
1010+ touch " ${FAKE_LOCAL_REPOSITORY} " /new-file-{1,2,3}.txt
1011+
1012+ run git_auto_commit
1013+
1014+ assert_success
1015+
1016+ assert_line " INPUT_REPOSITORY value: ${INPUT_REPOSITORY} "
1017+ assert_line " INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH} "
1018+ assert_line " INPUT_FILE_PATTERN: ."
1019+ assert_line " INPUT_COMMIT_OPTIONS: "
1020+ assert_line " ::debug::Apply commit options "
1021+ assert_line " INPUT_TAGGING_MESSAGE: "
1022+ assert_line " No tagging message supplied. No tag will be added."
1023+ assert_line " INPUT_PUSH_OPTIONS: "
1024+ assert_line " ::debug::Apply push options "
1025+ assert_line " ::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH} "
1026+
1027+ assert_line " ::set-output name=changes_detected::true"
1028+ assert_line -e " ::set-output name=commit_hash::[0-9a-f]{40}$"
1029+ }
1030+
1031+ @test " It uses old set-output syntax if GITHUB_OUTPUT environment is not available when no changes have been detected" {
1032+ unset GITHUB_OUTPUT
1033+
1034+ run git_auto_commit
1035+
1036+ assert_success
1037+
1038+ assert_line " INPUT_REPOSITORY value: ${INPUT_REPOSITORY} "
1039+ assert_line " Working tree clean. Nothing to commit."
1040+
1041+ assert_line " ::set-output name=changes_detected::false"
1042+ refute_line -e " ::set-output name=commit_hash::[0-9a-f]{40}$"
1043+ }
0 commit comments