Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ updates:
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 4
3 changes: 3 additions & 0 deletions .github/workflows/build-devel-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Scheduled build for devel docs
# Run at 05:22 daily
- cron: '22 5 * * *'

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-latest-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Scheduled build for latest docs
# Run at 05:41 on Monday
- cron: '41 5 * * 1'

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-package-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ name: Build and deploy docs
- production
- test

permissions:
contents: read

jobs:
build-package-docs:
name: 📝 Build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ name: Ansible Docsite CI
- ready_for_review # used in PRs created from GitHub Actions workflows
workflow_dispatch:

permissions:
contents: read

jobs:
nox:
uses: ./.github/workflows/reusable-nox.yml
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later

"on":
pull_request_target:
# This workflow does not execute untrusted code from pull requests and all
# inputs are properly sanitized,
pull_request_target: # zizmor: ignore[dangerous-triggers]
types:
- opened # default
- synchronize # default
Expand All @@ -29,6 +31,9 @@

name: "Triage Issues and PRs"

permissions:
contents: read

jobs:
label_prs:
runs-on: ubuntu-latest
Expand All @@ -48,6 +53,8 @@ jobs:
private-key: ${{ secrets.BOT_APP_KEY }}
- name: Checkout parent repository
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Install Python 3.12
uses: actions/setup-python@v6
with:
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/pip-compile-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ name: "Refresh dev dependencies"
required: false
type: string

permissions:
contents: read

jobs:
refresh:
strategy:
Expand Down Expand Up @@ -71,4 +74,9 @@ jobs:
python-versions: "${{ matrix.python-versions }}"
reset-branch: "${{ inputs.reset-branch || false }}"
labels: "${{ inputs.labels || 'no_backport,tooling' }}"
secrets: inherit
# Pass using inherit, as this seems to be the only possible way to access
# secrets defined in an enviornment when using nested workflows.
secrets: inherit # zizmor: ignore[secrets-inherit]
# secrets:
# BOT_APP_ID: "${{ secrets.BOT_APP_ID }}"
# BOT_APP_KEY: "${{ secrets.BOT_APP_KEY }}"
10 changes: 9 additions & 1 deletion .github/workflows/pip-compile-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ name: "Refresh docs build dependencies"
required: false
type: string

permissions:
contents: read

jobs:
refresh:
name: "Refresh docs build dependencies"
Expand All @@ -33,4 +36,9 @@ jobs:
reset-branch: "${{ inputs.reset-branch || false }}"
labels: "${{ inputs.labels || 'doc builds,no_backport' }}"
python-versions: "3.12"
secrets: inherit
# Pass using inherit, as this seems to be the only possible way to access
# secrets defined in an enviornment when using nested workflows.
secrets: inherit # zizmor: ignore[secrets-inherit]
# secrets:
# BOT_APP_ID: "${{ secrets.BOT_APP_ID }}"
# BOT_APP_KEY: "${{ secrets.BOT_APP_KEY }}"
4 changes: 4 additions & 0 deletions .github/workflows/release-porting-guide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
description: >-
Exact release version. For example, 12.1.0
required: true
permissions:
contents: read

jobs:
upload-porting-guide:
Expand Down Expand Up @@ -40,13 +42,15 @@ jobs:
uses: actions/checkout@v5
with:
token: ${{ steps.create_token.outputs.token }}
persist-credentials: true # Needed to push to the repo

- name: Check out ansible-build-data
uses: actions/checkout@v5
with:
repository: ansible-community/ansible-build-data
ref: ${{ inputs.ansible-build-data-branch }}
path: ansible-build-data
persist-credentials: false

- name: Copy the RST file to the correct path
run: >-
Expand Down
27 changes: 15 additions & 12 deletions .github/workflows/reusable-build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ name: Build docs
DOCS_BOT_TOKEN:
required: true

env:
PACKAGE_VERSION: ${{ inputs.ansible-package-version }}

jobs:
build-package-docs:
runs-on: ubuntu-latest
Expand All @@ -50,6 +47,7 @@ jobs:
}}
ref: ${{ inputs.repository-branch }}
path: build-directory
persist-credentials: false

- name: Setup nox
uses: wntrblm/nox@2025.10.16
Expand All @@ -68,19 +66,22 @@ jobs:
-c tests/requirements.txt
working-directory: build-directory

- name: Set the VERSION variable
run: echo VERSION="${PACKAGE_VERSION}" >> "${GITHUB_ENV}"

- name: Build the Ansible community package docs
run: >-
make webdocs ${{
env:
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
run: |
# Clear PACKAGE_VERSION if it's set to devel
if [ "${PACKAGE_VERSION}" = "devel" ]; then
PACKAGE_VERSION=""
fi
make webdocs ANSIBLE_VERSION="${PACKAGE_VERSION}" ${{
inputs.generate-redirects && 'EXTRA_TAGS="-t redirects"' || ''
}} ANSIBLE_VERSION="${{
env.PACKAGE_VERSION != 'devel' && env.PACKAGE_VERSION || ''
}}"
}}
working-directory: build-directory/docs/docsite

- name: Create a tarball with the build contents
env:
PACKAGE_VERSION: "${{ inputs.ansible-package-version }}"
run: >-
tar -czvf
ansible-package-docs-html-"${PACKAGE_VERSION}"-"$(date '+%Y-%m-%d')"-${{
Expand Down Expand Up @@ -116,8 +117,10 @@ jobs:
run: echo "TX_ID=$(date +%s)" >> "${GITHUB_ENV}"

- name: Notify the DaWGs in Matrix
# FAIL_MESSAGE is trusted input so okay to inject here.
# zizmor: ignore[template-injection]
run: |
curl -X PUT "${{ env.ROOM_URL }}/${TX_ID}" \
curl -X PUT "${ROOM_URL}/${TX_ID}" \
-H "Authorization: Bearer ${{ secrets.DOCS_BOT_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{"msgtype": "m.text", "body": "${{ env.FAIL_MESSAGE }}"}'
13 changes: 9 additions & 4 deletions .github/workflows/reusable-deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Log the workflow inputs if deployed
env:
deployment_environment: "${{ inputs.deployment-environment }}"
package_version: "${{ inputs.ansible-package-version }}"
owner: "${{ inputs.repository-owner }}"
branch: "${{ inputs.repository-branch }}"
run: |
{
echo "## Deployment details :shipit:";
echo "Publish to: ${{ inputs.deployment-environment }}";
echo "Package version: ${{ inputs.ansible-package-version }}";
echo "Owner: ${{ inputs.repository-owner }}";
echo "Branch: ${{ inputs.repository-branch }}";
echo "Publish to: ${deployment_environment}";
echo "Package version: ${package_version}";
echo "Owner: ${owner}";
echo "Branch: ${branch}";
} >> "${GITHUB_STEP_SUMMARY}"

deploy-package-docs:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/reusable-nox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ jobs:
- session: "pip-compile"
extra-args: "--check"
python-versions: "3.12"
- session: "zizmor"
python-versions: "3.12"
Comment on lines +37 to +38
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially remove this in favor of the workflow added in #3141 and just keep the zizmor in the noxfile for contributors to run locally.

Although, I'm concerned that:

  1. The zizmor workflow in Add Zizmor Scanning on push/pull request #3141 doesn't make CI red even though there are failures.
  2. If we have to manage the zizmor version pinned in the zizmor workflow and the version used by the nox job, they may get out of sync, which could be confusing for developers, as they'll get different results when running locally vs. CI.
  3. I'm not sure how much the integration with Github Code Scanning is helpful to our community. Case in point, @x1101 spent time contributing the workflow (thank you!), but they can't even see the failures it reported. I personally think it's better to integrate zizmor with our existing nox setup but am happy to be convinced otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The zizmor workflow not failing CI seems to be by design of the GHA author, keeping that data in the security section for action separate from success/failure of the CI itself.

As for not being able to find the reported issues, that was a "I needed to learn how to use the tools together". I was running the scans on one branch, and the scan was showing data from another, and I just missed how I could adjust that to see the results (all of that was happening in my own fork).

With all that being said, since a majority of the workflows for the project are setup using nox to make them portable between dev/CI environments, I can't think of any good objections to integrating it there. I initially went the GHA route because it appears to be the suggested method by the tool authors, with the intention of piping that data automatically into existing GH systems (which does work as intended, but doesn't sound like its exactly the use case we're targeting).

name: "Run nox ${{ matrix.session }} session"
steps:
- name: Check out repo
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Setup nox
uses: wntrblm/nox@2025.10.16
with:
Expand All @@ -46,7 +50,8 @@ jobs:
run: |
nox -e clone-core
- name: "Run nox -e ${{ matrix.session }}"
# Using GHA expression interpolation is fine here,
# as we control all the inputs.
# zizmor: ignore[template-injection]
run: |
# Using GHA expression interpolation is fine here,
# as we control all the inputs.
nox -e "${{ matrix.session }}" -- ${{ matrix.extra-args }}
28 changes: 20 additions & 8 deletions .github/workflows/reusable-pip-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,21 @@ name: "Refresh pinned dependencies"
python-versions:
type: string
required: true

permissions:
contents: read

jobs:
refresh:
runs-on: ubuntu-latest
environment: github-bot
steps:
- name: Generate temp GITHUB_TOKEN
id: create_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
- name: Check out repo
uses: actions/checkout@v5
with:
fetch-depth: 0
ref: "${{ inputs.base-branch }}"
token: "${{ steps.create_token.outputs.token }}"
persist-credentials: false
- name: Fetch required contents of ansible-core
run: |
python docs/bin/clone-core.py
Expand Down Expand Up @@ -82,9 +80,23 @@ jobs:
env:
# Ensure the latest pip version is used
VIRTUALENV_DOWNLOAD: '1'
#
# nox-args is defined statically in the calling workflows and passing it
# as a shell variable presents quoting issues, so ignore zizmor error
# for now.
# zizmor: ignore[template-injection]
run: |
nox ${{ inputs.nox-args }}
- name: Generate temp GITHUB_TOKEN
id: create_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
# We could rely on the checkout action to persist the token in the
# repository config, but this way, we can prevent the previous steps
# from having unnecessary access.
- name: "Set up token authentication"
run: gh auth setup-git --force --hostname github.com
- name: Push new dependency versions and create a PR
env:
GITHUB_TOKEN: ${{ steps.create_token.outputs.token }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ name: Sync tags with ansible-core releases
schedule:
- cron: "0 * * * *" # Hourly

permissions:
contents: read # read-only because we use bot token to push

jobs:
tag:
runs-on: "ubuntu-latest"
Expand All @@ -30,12 +33,14 @@ jobs:
path: ansible-documentation
fetch-depth: 0
token: "${{ steps.create_token.outputs.token }}"
persist-credentials: true
- name: Check out core
uses: actions/checkout@v5
with:
repository: ansible/ansible
path: ansible
fetch-depth: 0
persist-credentials: false
- name: Setup nox
uses: wntrblm/nox@2025.10.16
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
unpinned-uses:
config:
policies:
"wntrblm/nox": ref-pin
"re-actors/alls-green": ref-pin
"actions/*": ref-pin
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The `nox` configuration also contains session to run automated docs checkers.
If you want to view the generated HTML in your browser, you should build the documentation locally.
See [Building the documentation locally](https://docs.ansible.com/ansible/latest/community/documentation_contributions.html#building-the-documentation-locally) for more information.

* Lint, type check, and format Python scripts in this repository.
* Lint, type check, and format Python scripts in this repository and lint the Github Actions workflows for syntax and security issues:

``` bash
nox -s lint
Expand Down
9 changes: 9 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ def actionlint(session: nox.Session) -> None:
)


@nox.session
def zizmor(session: nox.Session) -> None:
"""
Ren zizmor, a Github Actions security checker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ren zizmor, a Github Actions security checker
Run zizmor, a Github Actions security checker

"""
install(session, req="zizmor")
session.run("zizmor", "--persona=regular", ".github/workflows")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to allow passing the persona as an arg?

It could be persona by default but perhaps there could be cases where I'd want to use this session to conduct an audit and set --persona=auditor. I think this flexibility would give the nox session approach more of an advantage over the workflow.



@nox.session
def lint(session: nox.Session):
session.notify("typing")
Expand Down
1 change: 1 addition & 0 deletions tests/zizmor.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zizmor
4 changes: 4 additions & 0 deletions tests/zizmor.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --universal --output-file tests/zizmor.txt tests/zizmor.in
zizmor==1.16.0
# via -r tests/zizmor.in