-
Notifications
You must be signed in to change notification settings - Fork 1
Chore: [AEA-0000] - add pre-commit hooks, update docs, tighten security on workflows #9
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| id-token: write | ||
| password: \${{secrets\.GITHUB_TOKEN}} | ||
| token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"? | ||
| github-token: ?"?\$\{\{\s*secrets\.GITHUB_TOKEN\s*\}\}"? | ||
| token: ?"?\$\{\{\s*secrets\.DEPENDABOT_TOKEN\s*\}\}"? | ||
| \.gitallowed | ||
| id-token: "write" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Update devcontainer version | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "0 6 * * 1" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| update-devcontainer-version: | ||
| runs-on: ubuntu-22.04 | ||
| environment: create_pull_request | ||
| permissions: | ||
| contents: read | ||
| packages: read | ||
|
|
||
| steps: | ||
| - name: Update devcontainer version | ||
| uses: NHSDigital/eps-update-devcontainer@95118f6746ca7081258cc7f651dca1c5bb7339f1 | ||
| with: | ||
| calling_repo_base_branch: main | ||
| CREATE_PULL_REQUEST_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_APP_ID }} | ||
| CREATE_PULL_REQUEST_PEM: ${{ secrets.CREATE_PULL_REQUEST_PEM }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: check-merge-conflict | ||
| name: Check for merge conflict strings | ||
|
|
||
| - id: end-of-file-fixer | ||
| name: Fix missing newline at the end of files | ||
|
|
||
| - id: check-shebang-scripts-are-executable | ||
| name: Check shell scripts are executable | ||
| files: \.(sh)$ | ||
|
|
||
| - id: check-yaml | ||
| name: Check pipelines configuration | ||
| files: ^(.github) | ||
|
|
||
| - repo: https://github.com/pycqa/flake8 | ||
| rev: "7ef0350a439c93166bc8ba89fcc3de6a9a664e6c" | ||
| hooks: | ||
| - id: flake8 | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: zizmor-action | ||
| name: Check action.yml | ||
| entry: zizmor | ||
| args: ["action.yml"] | ||
| language: system | ||
| files: action.yml | ||
| pass_filenames: false | ||
|
|
||
| - id: lint-githubactions | ||
| name: Lint github actions | ||
| entry: make | ||
| args: ["actionlint"] | ||
| language: system | ||
| files: ^.github | ||
| types_or: [yaml] | ||
| pass_filenames: false | ||
|
|
||
| - id: lint-githubaction-scripts | ||
| name: Lint github action scripts | ||
| entry: make | ||
| args: ["shellcheck"] | ||
| language: system | ||
| files: ^.github/scripts | ||
| types_or: [sh, shell] | ||
| pass_filenames: false | ||
|
Comment on lines
+15
to
+50
|
||
|
|
||
| - id: check-commit-signing | ||
| name: Check commit signing | ||
| description: Ensures that commits are GPG signed | ||
| entry: bash | ||
| args: | ||
| - -c | ||
| - | | ||
| if ! git config --get user.signingkey > /dev/null 2>&1; then | ||
| echo "Error: Git signing key not configured." | ||
| echo "Please configure your GPG signing key with:" | ||
| echo " git config user.signingkey <YOUR_GPG_KEY_ID>" | ||
| echo "" | ||
| echo "To find your GPG key ID, run: gpg --list-secret-keys --keyid-format=long" | ||
| echo "For more information, see: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits" | ||
| exit 1 | ||
| fi | ||
| if ! git config --get commit.gpgsign | grep -q "true" > /dev/null 2>&1; then | ||
| echo "Error: Commit signing is not enabled." | ||
| echo "Please enable commit signing with:" | ||
| echo " git config commit.gpgsign true" | ||
| echo "" | ||
| echo "For more information, see: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits" | ||
| exit 1 | ||
| fi | ||
| echo "Commit signing is properly configured." | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
|
|
||
| - id: git-secrets | ||
| name: Git Secrets | ||
| description: git-secrets scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories. | ||
| entry: bash | ||
| args: | ||
| - -c | ||
| - "git-secrets --pre_commit_hook" | ||
| language: system | ||
|
|
||
| fail_fast: true | ||
| default_stages: [pre-commit] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,8 +1,11 @@ | ||||||
| .PHONY: install install-node compile lint test | ||||||
|
||||||
| .PHONY: install install-node compile lint test | |
| .PHONY: install install-node install-python install-hooks compile lint test |
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.
The local hooks
zizmorandgit-secretsuselanguage: system, but neither tool is installed viapoetry install(they’re not inpyproject.toml/poetry.lock) and the Makefile install flow doesn’t install them either. This will makepre-commitfail on fresh setups unless the tools are preinstalled; consider adding installation steps (or switching to pre-commit-managed hooks / documenting the required system dependencies).