From 01e21517f45582c55bd997b56ed72e14d1359759 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Mon, 16 Nov 2026 20:17:31 +0100 Subject: [PATCH 1/2] chore: tighten GitHub Actions permissions --- .github/actions/setup-bun/action.yml | 15 ++- .github/dependabot.yml | 10 +- .github/workflows/claude-code-review-run.yml | 3 + .github/workflows/claude-code-review.yml | 2 + .github/workflows/claude-issue-agent.yml | 3 + .github/workflows/cli-docs.yml | 2 + .github/workflows/codeql.yml | 4 + .github/workflows/command-analyze.yml | 2 + .github/workflows/command-backport.yml | 2 +- .github/workflows/command-fix.yml | 2 + .github/workflows/default.yml | 5 +- .github/workflows/docs-issue.yml | 4 +- .github/workflows/documentation.yml | 2 + .github/workflows/hassio-changelog.yml | 2 + .github/workflows/language-reminder.yml | 118 ------------------- .github/workflows/nightly-docker.yml | 6 +- .github/workflows/nightly.yml | 1 - .github/workflows/openapi-validate.yml | 2 + .github/workflows/release.yml | 7 +- .github/workflows/schema.yml | 2 + .github/workflows/stale.yaml | 2 + Dockerfile | 2 +- 22 files changed, 63 insertions(+), 135 deletions(-) delete mode 100644 .github/workflows/language-reminder.yml diff --git a/.github/actions/setup-bun/action.yml b/.github/actions/setup-bun/action.yml index d5215c300b..464d2bf773 100644 --- a/.github/actions/setup-bun/action.yml +++ b/.github/actions/setup-bun/action.yml @@ -8,6 +8,9 @@ inputs: version: description: Bun version, keep in sync with the pinned claude-code-action default: 1.4.4 + sha256: + description: Checksum of bun-linux-x64.zip for that version, from the release's SHASUMS256.txt + default: bf8ccbfb2b0b80159e0f9a6d15c55317add8077534dbc6130a3edb52fccb395c outputs: path: @@ -21,8 +24,8 @@ runs: id: cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 with: - path: ${{ runner.temp }}/bun - key: ${{ runner.os }}-bun-${{ inputs.version }} + path: ${{ runner.temp }}/bun.zip + key: ${{ runner.os }}-bun-${{ inputs.version }}-${{ inputs.sha256 }} - name: Download Bun if: steps.cache.outputs.cache-hit != 'true' @@ -32,5 +35,13 @@ runs: run: | curl -fsSL --retry 6 --retry-all-errors --retry-delay 15 -o "$RUNNER_TEMP/bun.zip" \ "https://github.com/oven-sh/bun/releases/download/bun-v$VERSION/bun-linux-x64.zip" + + # the archive is cached, so a restored copy is checked as well + - name: Verify and unpack Bun + shell: bash + env: + SHA256: ${{ inputs.sha256 }} + run: | + echo "$SHA256 $RUNNER_TEMP/bun.zip" | sha256sum -c - unzip -q -j -o "$RUNNER_TEMP/bun.zip" -d "$RUNNER_TEMP/bun" "$RUNNER_TEMP/bun/bun" --version diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 794d860db5..9e5354f9ec 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,13 @@ version: 2 updates: - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/.github/actions/*" schedule: interval: "monthly" + cooldown: + default-days: 7 labels: - "infrastructure" # init and analyze must run the same version, SHA pins make them separate dependencies @@ -15,6 +19,8 @@ updates: directory: "/" schedule: interval: "monthly" + cooldown: + default-days: 7 labels: - "infrastructure" - package-ecosystem: "gomod" @@ -36,5 +42,7 @@ updates: directory: "/.github" schedule: interval: "monthly" + cooldown: + default-days: 7 labels: - "infrastructure" diff --git a/.github/workflows/claude-code-review-run.yml b/.github/workflows/claude-code-review-run.yml index 92656f816b..9a1a169563 100644 --- a/.github/workflows/claude-code-review-run.yml +++ b/.github/workflows/claude-code-review-run.yml @@ -15,6 +15,8 @@ on: workflows: ["Claude Code Review"] types: [completed] +permissions: {} + jobs: gate: # Only react to PR runs that finished successfully. @@ -96,6 +98,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 1 + persist-credentials: false - name: Setup Bun id: bun diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index 6833e407db..a5179c24a1 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -12,6 +12,8 @@ concurrency: group: claude-review-${{ github.event.pull_request.number }} cancel-in-progress: true +permissions: {} + jobs: prepare: # Skip draft PRs diff --git a/.github/workflows/claude-issue-agent.yml b/.github/workflows/claude-issue-agent.yml index cd5070f1aa..9dd0f30278 100644 --- a/.github/workflows/claude-issue-agent.yml +++ b/.github/workflows/claude-issue-agent.yml @@ -1,5 +1,7 @@ name: Claude Issue & PR Agent +permissions: {} + on: issues: # reopened: the triage agent closes incomplete reports and asks the reporter @@ -154,6 +156,7 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: fetch-depth: 0 + persist-credentials: false - name: Setup Bun id: bun diff --git a/.github/workflows/cli-docs.yml b/.github/workflows/cli-docs.yml index af211bd216..3d8b5fda5e 100644 --- a/.github/workflows/cli-docs.yml +++ b/.github/workflows/cli-docs.yml @@ -1,5 +1,7 @@ name: Deploy CLI docs +permissions: {} + on: release: types: [created] diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f2b7707288..54d08e2d5c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,8 @@ # name: "CodeQL" +permissions: {} + on: push: branches: [master] @@ -62,6 +64,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false # Add any setup steps before running the `github/codeql-action/init` action. # This includes steps like installing compilers or runtimes (`actions/setup-node` diff --git a/.github/workflows/command-analyze.yml b/.github/workflows/command-analyze.yml index 90bcfb1f2c..485c57a07d 100644 --- a/.github/workflows/command-analyze.yml +++ b/.github/workflows/command-analyze.yml @@ -1,5 +1,7 @@ name: Claude Analyze Command +permissions: {} + on: issue_comment: types: [created] diff --git a/.github/workflows/command-backport.yml b/.github/workflows/command-backport.yml index 90db3bef20..2e384fc8a3 100644 --- a/.github/workflows/command-backport.yml +++ b/.github/workflows/command-backport.yml @@ -28,7 +28,7 @@ jobs: contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association) runs-on: depot-ubuntu-24.04-arm permissions: - contents: write + contents: read issues: write pull-requests: write diff --git a/.github/workflows/command-fix.yml b/.github/workflows/command-fix.yml index 285e673666..8981f1ac6e 100644 --- a/.github/workflows/command-fix.yml +++ b/.github/workflows/command-fix.yml @@ -1,5 +1,7 @@ name: Claude Fix Command +permissions: {} + on: issue_comment: types: [created] diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index c6f70c8300..2ade0b17ff 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -1,5 +1,7 @@ name: Default +permissions: {} + on: push: branches: @@ -120,7 +122,6 @@ jobs: name: UI permissions: contents: read - actions: write runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-24.04-arm' || 'depot-ubuntu-24.04-arm' }} steps: @@ -190,7 +191,6 @@ jobs: permissions: contents: read - actions: write # the Playwright run is the longest step of the workflow, so it is split strategy: @@ -328,7 +328,6 @@ jobs: permissions: contents: read - actions: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 diff --git a/.github/workflows/docs-issue.yml b/.github/workflows/docs-issue.yml index 84d19d07ad..437a8ab4c5 100644 --- a/.github/workflows/docs-issue.yml +++ b/.github/workflows/docs-issue.yml @@ -1,7 +1,5 @@ name: Create Documentation Issue -permissions: - issues: write - contents: read +permissions: {} on: pull_request_target: diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 0cfeb66460..95ad40ea6b 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,5 +1,7 @@ name: Deploy updated templates +permissions: {} + on: schedule: - cron: "0 2 * * *" # same time as nightly is triggered diff --git a/.github/workflows/hassio-changelog.yml b/.github/workflows/hassio-changelog.yml index 228c8345cd..06bb19c931 100644 --- a/.github/workflows/hassio-changelog.yml +++ b/.github/workflows/hassio-changelog.yml @@ -1,5 +1,7 @@ name: Hassio Addon Changelog Update (Reusable) +permissions: {} + on: workflow_call: inputs: diff --git a/.github/workflows/language-reminder.yml b/.github/workflows/language-reminder.yml deleted file mode 100644 index 66e6b2c997..0000000000 --- a/.github/workflows/language-reminder.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: Language Reminder - -on: - pull_request_review_comment: - types: [created] - issue_comment: - types: [created] - issues: - types: [opened] - -permissions: - pull-requests: write - issues: write - contents: read - models: read - -jobs: - check-language: - name: Check Comment Language - runs-on: ubuntu-latest - # temporary disable to due high false-positive rate - if: false && (github.event.issue.pull_request || github.event.pull_request) - - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - - name: Check language - id: language_check - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 - env: - COMMENT_BODY: ${{ github.event.comment.body }} - GITHUB_TOKEN: ${{ github.token }} - with: - script: | - // Use environment variable for security (prevents injection) - const commentBody = process.env.COMMENT_BODY; - - const response = await fetch('https://models.github.ai/inference/chat/completions', { - method: 'POST', - headers: { - 'Authorization': `Bearer ${process.env.GITHUB_TOKEN}`, - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - model: 'openai/gpt-4o-mini', - messages: [ - { - role: 'system', - content: 'This project requires English communication to ensure everyone can participate. Determine if a user comment requires a language reminder. The comment is markdown formatted. When analyzing: ignore text inside markdown code blocks (```), code suggestions, and quotes (>) as these may contain translations/i18n content (e.g. "de: Text"). Only analyze the regular text content. Short comments (one sentence) should not be flagged. Return `true` if you think a reminder to switch to English is needed, `false` otherwise. When unsure, return `false`.' - }, - { - role: 'user', - content: commentBody - } - ], - response_format: { - type: 'json_schema', - json_schema: { - name: 'language_check', - strict: true, - schema: { - type: 'object', - properties: { - requires_reminder: { type: 'boolean' } - }, - required: ['requires_reminder'], - additionalProperties: false - } - } - }, - max_tokens: 200 - }) - }); - - if (!response.ok) { - const errorText = await response.text(); - throw new Error(`Inference failed: ${response.statusText} - ${errorText}`); - } - - const result = await response.json(); - const analysis = JSON.parse(result.choices[0].message.content); - core.setOutput('analysis', JSON.stringify(analysis)); - return analysis; - - - name: Post reminder if non-English - if: steps.language_check.outputs.analysis != '' - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 - with: - script: | - const analysis = JSON.parse('${{ steps.language_check.outputs.analysis }}'); - console.log('Analysis:', analysis); - - if (analysis.requires_reminder) { - const comment = context.payload.comment; - const reminderMessage = `@${comment.user.login} 🇬🇧 Please use English so everyone can participate. See [Contributing Guidelines](https://github.com/${context.repo.owner}/${context.repo.repo}/blob/master/CONTRIBUTING.md#communication-language).`; - - // Handle different event types - if (context.eventName === 'pull_request_review_comment') { - // Review comment on PR - reply in thread - await github.rest.pulls.createReviewComment({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.pull_request.number, - body: reminderMessage, - commit_id: comment.commit_id, - path: comment.path, - in_reply_to: comment.id - }); - } else if (context.eventName === 'issue_comment' && context.payload.issue.pull_request) { - // Comment on PR issue - post as issue comment - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.issue.number, - body: reminderMessage - }); - } - } diff --git a/.github/workflows/nightly-docker.yml b/.github/workflows/nightly-docker.yml index ee4be4576b..7b7e8ae014 100644 --- a/.github/workflows/nightly-docker.yml +++ b/.github/workflows/nightly-docker.yml @@ -6,6 +6,8 @@ name: Nightly Docker on: workflow_call: +permissions: {} + jobs: docker: name: Publish Docker :nightly @@ -52,9 +54,11 @@ jobs: tags: ${{ steps.meta.outputs.tags }} - name: Delete old nightly.* tags + env: + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} run: | old_tags=$(curl -s "https://hub.docker.com/v2/repositories/evcc/evcc/tags/?page_size=100" | jq -r '.results | map(select(.name | startswith("nightly."))) | sort_by(.last_updated) | reverse | .[1:] | .[].name') for tag in $old_tags; do echo "Deleting tag: $tag" - curl -s -H "Authorization: Bearer ${{ secrets.DOCKER_PASS }}" -X DELETE "https://hub.docker.com/v2/repositories/evcc/evcc/tags/$tag/" + curl -s -H "Authorization: Bearer $DOCKER_PASS" -X DELETE "https://hub.docker.com/v2/repositories/evcc/evcc/tags/$tag/" done diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 37952ee0b6..e431f07fa7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -39,7 +39,6 @@ jobs: uses: ./.github/workflows/default.yml permissions: contents: read - actions: write docker: needs: diff --git a/.github/workflows/openapi-validate.yml b/.github/workflows/openapi-validate.yml index ba135277a6..1a87e5918c 100644 --- a/.github/workflows/openapi-validate.yml +++ b/.github/workflows/openapi-validate.yml @@ -19,6 +19,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false - name: Setup Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57c060aeb3..28afda9a4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,6 @@ jobs: uses: ./.github/workflows/default.yml permissions: contents: read - actions: write docker: name: Publish Docker :release @@ -94,7 +93,7 @@ jobs: runs-on: depot-ubuntu-24.04-arm permissions: - contents: write + contents: read actions: read steps: @@ -174,14 +173,14 @@ jobs: permissions: contents: read - env: - FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false - uses: superfly/flyctl-actions/setup-flyctl@ed8efb33836e8b2096c7fd3ba1c8afe303ebbff1 # master - run: flyctl deploy --local-only --config packaging/fly.toml + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} hassio: name: Hassio Addon diff --git a/.github/workflows/schema.yml b/.github/workflows/schema.yml index 95ea3ef9e8..bd24ec1fc4 100644 --- a/.github/workflows/schema.yml +++ b/.github/workflows/schema.yml @@ -1,5 +1,7 @@ name: Validate Schema +permissions: {} + on: push: paths: diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 60c5663d95..6348e8db1b 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -1,5 +1,7 @@ name: "Stale issue handler" +permissions: {} + on: workflow_dispatch: schedule: diff --git a/Dockerfile b/Dockerfile index 8c41b81a0a..9b1ea4203c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN make ui # STEP 2 build executable binary -FROM --platform=$BUILDPLATFORM golang:1.27.3-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.27.3-alpine@sha256:fa3d596898d9f126af7c01d14ee7597bab3f39cccf392ef36b69fe77cd681f18 AS builder # Install git + SSL ca certificates. # Git is required for fetching the dependencies. From 7c1e06b5a1ce87b66887002c8013d793bc9e0946 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Mon, 16 Nov 2026 20:22:02 +0100 Subject: [PATCH 2/2] chore: keep contents write for release provenance upload --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28afda9a4e..0c1078ffa6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: runs-on: depot-ubuntu-24.04-arm permissions: - contents: read + contents: write actions: read steps: