How to get status check from commit through? #245
-
Any advice on how to get the status checks to pass through without rerunning tests. I am using this action to update some badges which are outputs of the test coverage report. The action (due to pushing a commit) sadly resets the status check. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I assume you're talking about the missing status-check icons on the commits that have been pushed by the Action? You're PRs look like this: The answer I usually give to these questions is that you can switch to use private access tokens, so that the commits made by the Action will trigger your usual workflows: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs. But this can waste precious runner minutes. I personally follow the mantra: If the changes committed by "git-auto-commit" does not impact the logic of my code, I don't bother with using a personal access token. It just wastes runner-minutes. I can see the status checks on the previous commit in the GitHub UI. But I can see that this won't work if you use branch protection rules – which Github started to promote more heavily the last few days. If you use protected branches the "personal access token"-route is the only way to go. |
Beta Was this translation helpful? Give feedback.
-
Actually it's worse in mine, since my branch requires tests to pass it just shows a yellow dot and |
Beta Was this translation helpful? Give feedback.
-
I'll try something like this: - uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[skip ci] Writing coverage files & updating readme"
file_pattern: .coverage_scripts/coverage.md README.md
# Reference: https://github.com/bahmutov/eleventy-example/blob/main/.github/workflows/ci.yml#L27
# https://docs.github.com/en/rest/reference/repos#create-a-commit-status
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"context": "lint_and_test",
"state": "success",
"description": "Staging tests passed",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
|
Beta Was this translation helpful? Give feedback.
-
I see. I don't have much experience with protected branches. Or try the personal access token (it's not that complicated). Or you could maybe update your - uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[skip ci] Writing coverage files & updating readme"
file_pattern: .coverage_scripts/coverage.md README.md
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#repository_dispatchs
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/actions/workflows/lint_and_test.yml/dispatches \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"ref": ${{ github.sha }},
}' |
Beta Was this translation helpful? Give feedback.
-
the github.sha contains the sha for the commit before the update, this worked for me :
|
Beta Was this translation helpful? Give feedback.
the github.sha contains the sha for the commit before the update, this worked for me :