Skip to content

Restrict self-hosted runner job to trusted events only#189

Merged
DeqingSun merged 3 commits into
ch55xduinofrom
copilot/update-github-actions-workflow
Jul 4, 2026
Merged

Restrict self-hosted runner job to trusted events only#189
DeqingSun merged 3 commits into
ch55xduinofrom
copilot/update-github-actions-workflow

Conversation

Copilot AI commented Jul 4, 2026

Copy link
Copy Markdown

Any user can open a fork PR and trigger the real_hardware_test_on_self_hosted_runner job, which checks out PR code and runs it on the self-hosted runner — a direct code execution risk on the host machine.

Changes

  • Scope push trigger to ch55xduino branch and add workflow_dispatch; pull_request remains for hosted-runner jobs
  • Gate the self-hosted job with a job-level if: so it only runs on push or workflow_dispatch — never on PR events
  • Add permissions: contents: read at workflow level to minimize GITHUB_TOKEN scope
on:
  pull_request:
  push:
    branches:
      - ch55xduino
  workflow_dispatch:

permissions:
  contents: read

jobs:
  real_hardware_test_on_self_hosted_runner:
    # Only run on trusted events (push to default branch or manual dispatch) to prevent
    # untrusted PR code from executing on the self-hosted runner.
    if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
    needs: arduino-cli_compile_all
    runs-on: self-hosted

check_clang and arduino-cli_compile_all are unaffected and continue to run for all PRs on GitHub-hosted runners.

Copilot AI changed the title [WIP] Update GitHub Actions workflow for self-hosted runner security Restrict self-hosted runner job to trusted events only Jul 4, 2026
Copilot AI requested a review from DeqingSun July 4, 2026 18:28
@DeqingSun DeqingSun marked this pull request as ready for review July 4, 2026 20:14
@DeqingSun DeqingSun merged commit 1a8de8a into ch55xduino Jul 4, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants