Skip to content

Comments

Add workflow to auto-approve workflow runs on main branch#2962

Merged
plengauer merged 4 commits intomainfrom
copilot/add-workflow-approval-job
Feb 21, 2026
Merged

Add workflow to auto-approve workflow runs on main branch#2962
plengauer merged 4 commits intomainfrom
copilot/add-workflow-approval-job

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

Workflow runs triggered on main that land in action_required state (e.g. first-time contributor forks) are never automatically approved, requiring manual intervention.

Changes

  • New workflow .github/workflows/autoapprove_workflow_runs.yml:
    • Triggers on workflow_run completed events across all workflows ('*')
    • Single approve job gated by a YAML-level if — no logic inside the script:
      if: ${{ github.event.workflow_run.conclusion == 'action_required' && github.event.workflow_run.head_branch == 'main' }}
    • Approves the run via gh api POST .../actions/runs/$RUN_ID/approve
    • Requires only actions: write; run ID passed via env var to avoid injection
Original prompt

This section details on the original issue you should resolve

<issue_title>Approve workflows on main branch</issue_title>
<issue_description>Create a new workflow that approves workflow runs that need approval. Trigger should be workflows completed. The only job should have an if (on yml level), not inside the script checking whether the conclusion indicates that an approval js required. Similar, it should only allow the job to run if the branch is main.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: plengauer <100447901+plengauer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add workflow to auto-approve runs on main branch Add workflow to auto-approve workflow runs on main branch Feb 20, 2026
Copilot AI requested a review from plengauer February 20, 2026 00:46
@plengauer plengauer marked this pull request as ready for review February 20, 2026 07:26
@plengauer plengauer requested a review from moflwi as a code owner February 20, 2026 07:26
Copilot AI review requested due to automatic review settings February 20, 2026 07:26
@plengauer plengauer enabled auto-merge (squash) February 20, 2026 07:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a GitHub Actions workflow to automatically approve workflow_run executions on main that end up in action_required, avoiding manual approvals.

Changes:

  • Introduces a new .github/workflows/autoapprove_workflow_runs.yml workflow.
  • Triggers on workflow_run (completed) and conditionally runs an approval job.
  • Uses gh api with actions: write to approve the run by ID.

@plengauer plengauer merged commit ddc1b07 into main Feb 21, 2026
547 checks passed
@plengauer plengauer deleted the copilot/add-workflow-approval-job branch February 21, 2026 12:16
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.

Approve workflows on main branch

3 participants