-
Notifications
You must be signed in to change notification settings - Fork 3
fix github actions format and permissions #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: auto-merge | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: docs | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: release | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| name: test | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: push | ||
|
|
||
| jobs: | ||
|
|
@@ -20,17 +23,17 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.10', '3.11', '3.12', '3.13'] | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: make install-test | ||
| - name: Run tests | ||
| run: pytest -x | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: make install-test | ||
| - name: Run tests | ||
| run: pytest -x | ||
|
Comment on lines
+26
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# 1) Find non-SHA action refs in this workflow.
python - <<'PY'
import re
f = '.github/workflows/test.yml'
for i, line in enumerate(open(f), 1):
m = re.search(r'uses:\s*([^@\s]+)@([^\s]+)', line)
if m and not re.fullmatch(r'[0-9a-f]{40}', m.group(2)):
print(f"{f}:{i}: unpinned -> {line.strip()}")
PY
# 2) Check whether checkout in pytest job sets persist-credentials.
rg -n -A5 -B3 'pytest:|uses:\s*actions/checkout|persist-credentials' .github/workflows/test.ymlRepository: cuenca-mx/facturapi-python Length of output: 1545 Pin action SHAs and disable checkout credential persistence in the
Suggested fix- - uses: actions/checkout@v4
+ - uses: actions/checkout@<full_commit_sha_for_v4>
+ with:
+ persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
+ uses: actions/setup-python@<full_commit_sha_for_v5>🧰 Tools🪛 zizmor (1.25.2)[warning] 28-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [error] 28-28: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) [error] 30-30: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||
|
|
||
| coverage: | ||
| runs-on: ubuntu-latest | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: cuenca-mx/facturapi-python
Length of output: 145
🏁 Script executed:
Repository: cuenca-mx/facturapi-python
Length of output: 170
🏁 Script executed:
Repository: cuenca-mx/facturapi-python
Length of output: 1137
🌐 Web query:
mkdocs gh-deploy GITHUB_TOKEN contents write required💡 Result:
When using mkdocs gh-deploy within a GitHub Actions workflow, the GITHUB_TOKEN requires write permissions to the repository's contents to successfully push the documentation to the deployment branch (typically gh-pages) [1][2]. By default, some GitHub Actions environments may have restricted permissions (read-only) [2]. To grant the necessary access, you must explicitly define the permissions in your workflow YAML file [2]. To fix "Permission denied" or 403 errors during deployment, add the following permissions block to your job configuration [2]: permissions: contents: write This allows the GITHUB_TOKEN to commit and push changes to the repository, which is required for mkdocs gh-deploy to update the documentation branch [1][2]. Additionally, ensure your repository settings allow GitHub Actions to have write access. You can check this by navigating to your repository's Settings > Actions > General > Workflow permissions and verifying that "Read and write permissions" is selected [3][2]. Relying on specific permissions within the workflow file is considered more secure than granting broad write access to all workflows in the repository settings [2].
Citations:
Docs deployment will fail because
contents: readis set whilemkdocs gh-deploypushes togh-pages.Your workflow grants the default
GITHUB_TOKENread-only access (permissions: contents: read), butmkdocs gh-deploy --forceneedspermissions: contents: writeto push commits to the deployment branch.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents