Skip to content
Merged
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
12 changes: 12 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
# actionlint configuration: https://github.com/rhysd/actionlint/blob/main/docs/config.md
paths:
.github/workflows/apm-sync.yml:
ignore:
- 'property "workflow_(repository|sha)" is not defined in object type'
.github/workflows/autofix.yml:
ignore:
- 'property "workflow_(repository|sha)" is not defined in object type'
.github/workflows/config-sync.yml:
ignore:
- 'property "workflow_(repository|sha)" is not defined in object type'
.github/workflows/label-sync.yml:
ignore:
# Same job.workflow_* gap as lint.yml below.
Expand All @@ -21,3 +30,6 @@ paths:
ignore:
# Same job.workflow_* gap as lint.yml above.
- 'property "workflow_(repository|sha)" is not defined in object type'
.github/workflows/vendored-file-sync.yml:
ignore:
- 'property "workflow_(repository|sha)" is not defined in object type'
19 changes: 3 additions & 16 deletions .github/workflows/apm-materialize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,18 @@ jobs:

- name: Check for apm.yml
id: precheck
run: |
if [ ! -f apm.yml ]; then
echo "::notice::No apm.yml in this repo; nothing to materialize."
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
run: bash scripts/apm-materialize/check-manifest.sh

- name: Install apm CLI
if: steps.precheck.outputs.skip != 'true'
env:
# renovate: datasource=pypi depName=apm-cli
apm_cli_version: "0.35.0"
run: |
set -euo pipefail
# ubuntu-24.04 ships python3 + pip; install the pinned apm-cli for this user.
python3 -m pip install --user "apm-cli==${apm_cli_version}"
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"
run: bash scripts/apm-materialize/install-apm.sh

- name: Materialize primitives (apm install)
if: steps.precheck.outputs.skip != 'true'
run: |
set -euo pipefail
apm --version
apm install
run: bash scripts/apm-materialize/install.sh

- name: Refresh config-sync copies of the ai-toolkit instructions
# Keeps config-sync/files/.github/instructions/ in step with the
Expand Down
41 changes: 25 additions & 16 deletions .github/workflows/apm-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ jobs:

- name: Resolve GitHub App credentials
id: app
# This step reads the App key, so tests/app-key-confinement.py pins its
# `run:` by SHA-256 and lets no step but harden-runner run before it. A
# script fetched by an earlier step would escape both checks (#537).
# lint: allow-inline-script reviewed App-key emptiness check, pinned by tests/app-key-confinement.py
env:
APP_ID: ${{ inputs.app-id || vars.AUTOMATION_APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.app-private-key || secrets.AUTOMATION_APP_PRIVATE_KEY }}
Expand Down Expand Up @@ -142,6 +146,24 @@ jobs:
fi
echo "::warning title=APM Sync falls back to GITHUB_TOKEN::${reason} GITHUB_TOKEN can only open the PR when 'Allow GitHub Actions to create and approve pull requests' is enabled, and that PR does not trigger CI. See https://github.com/DevSecNinja/.github/blob/main/docs/automation-app.md"

- name: Checkout apm-sync scripts
# The apm-sync scripts ship with this reusable workflow: fetch them
# from the same commit of DevSecNinja/.github that the caller pinned.
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: .devsecninja-apm-sync
sparse-checkout: |-
scripts/apm-sync/
sparse-checkout-cone-mode: false
persist-credentials: false

- name: Move apm-sync scripts out of the workspace
# Outside the workspace the sync PR can't pick them up, and a code
# checkout doesn't delete them.
run: mv .devsecninja-apm-sync "${RUNNER_TEMP}/devsecninja-apm-sync"

- name: Generate App token
id: app-token
if: steps.app.outputs.available == 'true'
Expand All @@ -165,34 +187,21 @@ jobs:

- name: Check for apm.yml
id: precheck
run: |
if [ ! -f apm.yml ]; then
echo "::notice::No apm.yml in this repo; nothing to sync."
echo "skip=true" >> "${GITHUB_OUTPUT}"
else
echo "skip=false" >> "${GITHUB_OUTPUT}"
fi
run: bash "${RUNNER_TEMP}/devsecninja-apm-sync/scripts/apm-sync/check-manifest.sh"

- name: Install apm CLI
if: steps.precheck.outputs.skip != 'true'
env:
VERSION: ${{ inputs.apm-version }}
APM_INSTALL_DIR: ${{ runner.temp }}/apm/bin
APM_LIB_DIR: ${{ runner.temp }}/apm/lib/apm
run: |
set -euo pipefail
curl -sSL https://aka.ms/apm-unix | sh
echo "${APM_INSTALL_DIR}" >> "${GITHUB_PATH}"
run: bash "${RUNNER_TEMP}/devsecninja-apm-sync/scripts/apm-sync/install-apm.sh"

- name: Refresh APM primitives
if: steps.precheck.outputs.skip != 'true'
env:
PACKAGES: ${{ inputs.packages }}
run: |
set -euo pipefail
apm --version
# shellcheck disable=SC2086 # PACKAGES is an intentional arg list.
apm update --yes ${PACKAGES}
run: bash "${RUNNER_TEMP}/devsecninja-apm-sync/scripts/apm-sync/update.sh"

- name: Open sync PR
id: open-pr
Expand Down
49 changes: 22 additions & 27 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ jobs:
name: auto-fix formatting
runs-on: ubuntu-24.04
steps:
- name: Checkout autofix scripts
# The autofix scripts ship with this reusable workflow: fetch them from
# the same commit of DevSecNinja/.github that the caller pinned.
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: .devsecninja-autofix
sparse-checkout: |-
scripts/autofix/
sparse-checkout-cone-mode: false
persist-credentials: false

- name: Move autofix scripts out of the workspace
# Outside the workspace the formatters don't touch them and the commit
# doesn't pick them up, and a code checkout doesn't delete them.
run: mv .devsecninja-autofix "${RUNNER_TEMP}/devsecninja-autofix"

- name: Checkout code
# zizmor: ignore[artipacked]
# Persisted credentials are required: the final step commits the
Expand All @@ -62,42 +80,19 @@ jobs:
if: ${{ inputs.autofix-dprint }}
env:
CONFIG_DIR: ${{ inputs.autofix-config-dir }}
run: |-
if [ -n "${CONFIG_DIR}" ] && [ -f "${CONFIG_DIR}/dprint.json" ]; then
mise exec -- dprint fmt \
--config "${CONFIG_DIR}/dprint.json" \
--config-discovery=false
else
mise exec -- dprint fmt
fi
run: bash "${RUNNER_TEMP}/devsecninja-autofix/scripts/autofix/dprint.sh"

- name: Auto-fix with yamlfmt
if: ${{ inputs.autofix-yamlfmt }}
env:
CONFIG_DIR: ${{ inputs.autofix-config-dir }}
run: |-
if [ -n "${CONFIG_DIR}" ] && [ -f "${CONFIG_DIR}/.yamlfmt.yaml" ]; then
find . \( -name '*.yaml' -o -name '*.yml' \) -print0 |
xargs -0 mise exec -- yamlfmt -conf "${CONFIG_DIR}/.yamlfmt.yaml"
else
find . \( -name '*.yaml' -o -name '*.yml' \) -print0 |
xargs -0 mise exec -- yamlfmt
fi
run: bash "${RUNNER_TEMP}/devsecninja-autofix/scripts/autofix/yamlfmt.sh"

- name: Auto-fix with shfmt
if: ${{ inputs.autofix-shfmt }}
run: find . -name '*.sh' -print0 | xargs -0 mise exec -- shfmt --write
run: bash "${RUNNER_TEMP}/devsecninja-autofix/scripts/autofix/shfmt.sh"

- name: Commit and push auto-fix changes
env:
COMMIT_MESSAGE: ${{ inputs.commit-message }}
run: |-
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet; then
echo "No formatting changes to commit."
else
git add .
git commit -m "${COMMIT_MESSAGE}"
git push
fi
run: bash "${RUNNER_TEMP}/devsecninja-autofix/scripts/autofix/commit-and-push.sh"
Loading
Loading