@@ -766,3 +766,112 @@ jobs:
766766 git push --force --delete origin "${TO_DELETE}"
767767 env :
768768 TO_DELETE : ${{ steps.setup-test-branch.outputs.branch-name }}
769+ test-persist-credentials-false-branch-on-remote :
770+ runs-on : ubuntu-latest
771+ needs : [check-not-fork]
772+ permissions :
773+ contents : write
774+ steps :
775+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
776+ with :
777+ persist-credentials : false
778+ - name : Setup test branch
779+ id : setup-test-branch
780+ run : |
781+ BRANCH_NAME="test-creds-false-branch-on-remote-$(date +%s)"
782+
783+ git config --global user.name 'github-actions[bot]'
784+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
785+
786+ git checkout -b $BRANCH_NAME
787+ git push --set-upstream https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git $BRANCH_NAME
788+
789+ # output status here to manually verify file changes
790+ git status --porcelain=v2 --branch --untracked-files=no
791+
792+ echo $BRANCH_NAME > "test-file.txt"
793+ echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
794+ - uses : ./
795+ id : test-action
796+ continue-on-error : true
797+ with :
798+ token : ${{ github.token }}
799+ stage-all-files : true
800+ commit-message : ${{ steps.setup-test-branch.outputs.branch-name }}
801+ - name : Delete test branch
802+ if : ${{ always() }}
803+ run : |
804+ git push --force --delete https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "${TO_DELETE}"
805+ env :
806+ TO_DELETE : ${{ steps.setup-test-branch.outputs.branch-name }}
807+ - name : Check output
808+ run : |
809+ changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
810+
811+ if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
812+ echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
813+ exit 1
814+ fi
815+
816+ if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
817+ echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
818+ exit 1
819+ fi
820+
821+ echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
822+ env :
823+ RESPONSE : ${{ steps.test-action.outputs.commit-response }}
824+
825+ test-persist-credentials-false-branch-not-on-remote : # make sure the action works on a clean machine without building
826+ runs-on : ubuntu-latest
827+ needs : [check-not-fork]
828+ permissions :
829+ contents : write
830+ steps :
831+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
832+ with :
833+ persist-credentials : false
834+ - name : Setup test branch
835+ id : setup-test-branch
836+ run : |
837+ BRANCH_NAME="test-creds-false-branch-not-on-remote-$(date +%s)"
838+
839+ git config --global user.name 'github-actions[bot]'
840+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
841+
842+ git checkout -b $BRANCH_NAME
843+
844+ git status --porcelain=v2 --branch --untracked-files=no
845+
846+ echo $BRANCH_NAME > "test-file.txt"
847+ echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
848+ - uses : ./
849+ id : test-action
850+ with :
851+ token : ${{ github.token }}
852+ stage-all-files : true
853+ create-branch-on-remote : true
854+ commit-message : ${{ steps.setup-test-branch.outputs.branch-name }}
855+ - name : Delete test branch
856+ if : ${{ always() }}
857+ run : |
858+ git push --force --delete https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "${TO_DELETE}"
859+ env :
860+ TO_DELETE : ${{ steps.setup-test-branch.outputs.branch-name }}
861+ - name : Check output
862+ run : |
863+ changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
864+
865+ if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
866+ echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
867+ exit 1
868+ fi
869+
870+ if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
871+ echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
872+ exit 1
873+ fi
874+
875+ echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
876+ env :
877+ RESPONSE : ${{ steps.test-action.outputs.commit-response }}
0 commit comments