I am trying to use GitHub Actions to automatically increment the version of my project while building the artifact and check the new changes back into the main branch.
The workflow pushes the commit using a PAT for an account that is used only for this purpose so I was able to exclude that user from the branch protection rule requiring a PR for the main branch.
Because there is also a Required Status check for that branch the push fails with
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: error: Required status check "build / tests" is expected.
How can I have the version commits skip this check while enforcing this check for all other commits?
A recent feature, rulesets, provides more control, such as allowing specified actors to bypass status check requirements.
I had the same issue and tried many different potential solutions. The only thing I could do to get it to work was to create an account with admin permissions, allow force pushes only for that account, not enforce branch protection rules for admins, and then force push the changes (I'm using this action).
The workflow basically looks like this:
jobs:
update-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.SERVICE_ACCOUNT_GITHUB }}
submodules: true
fetch-depth: 0
## do my update ##
- name: Add and commit change
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Bump version" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
force: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With