Closed fluentmoheshwar closed 1 year ago
Hi there
The output the Action produces isn't great here. The output is not related to INPUT_PUSH_OPTIONS
. The Action just prints nothing if push_options
is not set.
As you probably saw, this is the actual error:
To https://github.com/fluentmoheshwar/fluentmoheshwar-site ! [remote rejected] main -> main (refusing to allow a GitHub App to create or update workflow
.github/workflows/codeql.yml
withoutworkflows
permission) error: failed to push some refs to 'https://github.com/fluentmoheshwar/fluentmoheshwar-site'
You use custom permissions in your workflow file. During the run the .github/workflows/codeql.yml
file was updated. It's a workflow run. Apparently GitHub adds special protection to those file.
You have 2 options:
Update your workflow to use workflows: write
permissions.
name: "Prettier"
on:
push:
branches: ["main"]
jobs:
fix:
name: Fix formatting issues
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
security-events: write
+ workflows: write
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actionsx/prettier@v2
with:
# prettier CLI arguments.
args: --write .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Prettified Code
Update your Prettier settings to not update .github/workflows/*.yml
files.
@stefanzweifel can you help me with this?
Silly me thought workflows
is a supported permission. Doesn't seem so. (Docs)
A quick internet search for "refusing to allow a GitHub App to create or update workflow" shows results that all point to personal access tokens:
If you really need your workflow to change other workflow files, you need to create a new personl access token, add it as a secret to the repository and then reference it in the actions/checkout
step (not in git-auto-commit)
See README for details: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs
I tried those and didn't work as I expected. So, I took a silly approach but works I added run: echo ".github" > ".prettierignore" then before running auto commit. I added run: rm ".prettierignore" and I prettify the workflow files manually.
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Stefan Zweifel @.> Sent: Friday, December 2, 2022 2:35:49 PM To: stefanzweifel/git-auto-commit-action @.> Cc: Moheshwar Amarnath Biswas @.>; Author @.> Subject: Re: [stefanzweifel/git-auto-commit-action] The workflow fails to run (Issue #266)
Silly me thought workflows is a supported permission. Doesn't seem so. (Docshttps://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs)
A quick internet search for "refusing to allow a GitHub App to create or update workflow" shows results that all point to personal access tokens:
If you really need your workflow to change other workflow files, you need to create a new personl access token, add it as a secret to the repository and then reference it in the actions/checkout step (not in git-auto-commit)
See README for details: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs
— Reply to this email directly, view it on GitHubhttps://github.com/stefanzweifel/git-auto-commit-action/issues/266#issuecomment-1334908632, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APTOM2LRZ2FSVEA2NBOT2ULWLGYGLANCNFSM6AAAAAASP2FJ7M. You are receiving this because you authored the thread.Message ID: @.***>
for future reference
I fixed this by creating a new PAT, gave it workflow
access + repo
access (not sure which ones i should of added)- Then copying the token into a GitHub Actions variable named WORKFLOW_TOKEN and assigning it in my actions/checkout:
steps:
- name: ⚙️ Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}
for future reference
I fixed this by creating a new PAT, gave it
workflow
access +repo
access (not sure which ones i should of added)- Then copying the token into a GitHub Actions variable named WORKFLOW_TOKEN and assigning it in my actions/checkout:steps: - name: ⚙️ Checkout Repository uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} fetch-depth: 0 token: ${{ secrets.WORKFLOW_TOKEN }}
Thank you
git-auto-commit Version
v4.15.4
Machine Type
Ubuntu (eg. ubuntu-latest)
Bug description
The workflow fails to run and logs INPUT_PUSH_OPTIONS: To https://github.com/fluentmoheshwar/fluentmoheshwar-site ! [remote rejected] main -> main (refusing to allow a GitHub App to create or update workflow
.github/workflows/codeql.yml
withoutworkflows
permission) error: failed to push some refs to 'https://github.com/fluentmoheshwar/fluentmoheshwar-site' Error: Invalid status code: 1Steps to reproduce
Create a workflow like the example. Run it.
Tried solutions
No response
Example Workflow
Relevant log output