Skip to content

chore(deps): update actions/checkout action to v6 #208

chore(deps): update actions/checkout action to v6

chore(deps): update actions/checkout action to v6 #208

Workflow file for this run

name: 'Test'
on:
push:
branches:
- main
pull_request:
jobs:
check-not-fork:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
permissions: {}
steps:
- name: Check if fork
run: |
echo "::notice::Action not triggered from a fork. Proceeding with tests."
test-branch-on-remote: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_on_remote-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
git status --porcelain=v2 --branch --untracked-files=no
echo $BRANCH_NAME > "test-file.txt"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-branch-not-on-remote: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_not_on_remote-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git status --porcelain=v2 --branch --untracked-files=no
echo $BRANCH_NAME > "test-file.txt"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
create-branch-on-remote: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-not-stage-all-files:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_not_stage_all_files-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
echo $BRANCH_NAME > "test-file1.txt"
echo $BRANCH_NAME > "test-file2.txt"
git add test-file1.txt
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: false
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-stage-all-files:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_stage_all_files-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
echo $BRANCH_NAME > "test-file1.txt"
echo $BRANCH_NAME > "test-file2.txt"
git add test-file1.txt
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 2 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-multiple-files:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_multiple_files-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
file_content="$(mktemp temp-random-file-XXXXXX)"
# generate a file with 500KB of As
yes A | head -c 500000 > "$file_content"
for i in {1..10}
do
cp "$file_content" "test-file$i.txt"
echo "test-file$i.txt size: $(stat -c '%s' test-file$i.txt)"
done
# remove the temp file as we don't want to commit it
rm "$file_content"
git add .
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: false
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 10 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 10 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-very-large-file:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_very_large_file-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
# generate a file with 25MB of As
yes A | head -c 25000000 > test-file.txt
echo "test-file.txt size: $(stat -c '%s' test-file.txt)"
git add .
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: false
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-multiple-large-files:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_multiple_large_files-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
large_file="$(mktemp temp-random-file-XXXXXX)"
# generate a file with 2.5MB of As
yes A | head -c 2500000 > "$large_file"
for i in {1..10}
do
cp "$large_file" "test-file$i.txt"
echo "test-file$i.txt size: $(stat -c '%s' test-file$i.txt)"
done
# remove the temp file as we don't want to commit it
rm "$large_file"
git add .
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: false
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 10 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 10 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-file-rename: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_file_rename-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
mv test-files/test-renames.old test-files/test-renames.new
git add .
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-modify-file: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_modify-file-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
echo "new file content" >> test-files/test-modify.txt
git add .
# output status here to manually verify file changes
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-delete-file: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_delete-file-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
rm test-files/test-delete.txt
git add .
# output status here to manually verify file changes
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-token-url: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_token_url-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global url.https://x-access-token:${{ github.token }}@github.com/.insteadOf https://github.com/
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
git status --porcelain=v2 --branch --untracked-files=no
echo $BRANCH_NAME > "test-file.txt"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-fail-if-no-changes: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_failure_no-changes-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
# output status here to manually verify file changes
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
continue-on-error: true
with:
token: ${{ github.token }}
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output is failure
if: ${{ steps.test-action.outcome == 'failure' }}
run: |
if [[ -z "${RESPONSE}" ]]; then
echo "Validation passed: commit-response is empty."
else
echo "Error: commit-response is expected to be empty but got not empty."
exit 1
fi
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
- name: Check output is success
if: ${{ steps.test-action.outcome == 'success' }}
run: |
echo "Error: action status is expected to be failure but got success."
exit 1
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
test-success-if-no-changes: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: true
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test_success_no-changes-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream origin $BRANCH_NAME
# output status here to manually verify file changes
git status --porcelain=v2 --branch --untracked-files=no
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
continue-on-error: true
with:
token: ${{ github.token }}
success-if-no-changes: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output is failure
if: ${{ steps.test-action.outcome == 'failure' }}
run: |
echo "Error: action status is expected to be success but got failure."
exit 1
- name: Check output is success
if: ${{ steps.test-action.outcome == 'success' }}
run: |
if [[ -z "${RESPONSE}" ]]; then
echo "Validation passed: commit-response is empty."
else
echo "Error: commit-response is expected to be empty but got not empty."
exit 1
fi
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete origin "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
test-persist-credentials-false-branch-on-remote:
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test-creds-false-branch-on-remote-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git push --set-upstream https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git $BRANCH_NAME
# output status here to manually verify file changes
git status --porcelain=v2 --branch --untracked-files=no
echo $BRANCH_NAME > "test-file.txt"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
continue-on-error: true
with:
token: ${{ github.token }}
stage-all-files: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}
test-persist-credentials-false-branch-not-on-remote: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
needs: [check-not-fork]
permissions:
contents: write
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false
- name: Setup test branch
id: setup-test-branch
run: |
BRANCH_NAME="test-creds-false-branch-not-on-remote-$(date +%s)"
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git checkout -b $BRANCH_NAME
git status --porcelain=v2 --branch --untracked-files=no
echo $BRANCH_NAME > "test-file.txt"
echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- uses: ./
id: test-action
with:
token: ${{ github.token }}
stage-all-files: true
create-branch-on-remote: true
commit-message: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Delete test branch
if: ${{ always() }}
run: |
git push --force --delete https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git "${TO_DELETE}"
env:
TO_DELETE: ${{ steps.setup-test-branch.outputs.branch-name }}
- name: Check output
run: |
changedFilesIfAvailable=$(echo ${RESPONSE} | jq -r '.data.createCommitOnBranch.commit.changedFilesIfAvailable')
if [[ -z "$changedFilesIfAvailable" || "$changedFilesIfAvailable" == "null" ]]; then
echo "Error: changedFilesIfAvailable is empty or null. Verify the output from test-action."
exit 1
fi
if [[ "$changedFilesIfAvailable" -ne 1 ]]; then
echo "Error: changedFilesIfAvailable is expected to be 1 but got $changedFilesIfAvailable."
exit 1
fi
echo "Validation passed: changedFilesIfAvailable is $changedFilesIfAvailable."
env:
RESPONSE: ${{ steps.test-action.outputs.commit-response }}