Skip to content

ci: use github app token to push (should work with protected branch)#2254

Merged
jdobes merged 1 commit intoRedHatInsights:masterfrom
jdobes:semantic_release_gh_app
Mar 13, 2026
Merged

ci: use github app token to push (should work with protected branch)#2254
jdobes merged 1 commit intoRedHatInsights:masterfrom
jdobes:semantic_release_gh_app

Conversation

@jdobes
Copy link
Member

@jdobes jdobes commented Mar 13, 2026

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Update the semantic-release GitHub workflow to use a GitHub App token for releases and support pushing to protected branches.

CI:

  • Switch semantic-release to use a GitHub App token instead of a personal access token for authentication in the release workflow.
  • Run the workflow-run-cleanup action earlier in the job to cancel previous builds before checkout.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the semantic-release GitHub Actions workflow to use a GitHub App token for authenticated operations (compatible with protected branches) and reorders steps to generate the token before checkout and build cancellation.

Sequence diagram for updated semantic release workflow token usage

sequenceDiagram
  participant GH as GitHub_Actions_Runner
  participant WF as semantic_release_workflow
  participant AT as create_github_app_token_action
  participant APP as GitHub_App_for_semantic_release
  participant CL as workflow_run_cleanup_action
  participant CO as checkout_action
  participant SR as semantic_release_step
  participant API as GitHub_API_protected_branch

  GH->>WF: Trigger workflow on push
  WF->>AT: Run create_github_app_token_action with app_id and private_key
  AT->>APP: Authenticate as GitHub App
  APP->>API: Request installation access token
  API-->>APP: Return installation access token
  APP-->>AT: Provide GitHub_App_token
  AT-->>WF: Output token as step_output

  WF->>CL: Run workflow_run_cleanup_action with GITHUB_TOKEN
  CL->>API: Cancel previous workflow_runs

  WF->>CO: Run checkout_action with persist_credentials false
  CO->>API: Fetch repository_code
  API-->>CO: Return repository_code

  WF->>SR: Run semantic_release_step with GH_TOKEN from app_token_output
  SR->>API: Perform versioning and push to protected_branch using app_token
  API-->>SR: Accept authenticated_operations on protected_branch
Loading

File-Level Changes

Change Details Files
Switch semantic-release authentication from a personal/access token secret to a GitHub App token and wire it into the workflow.
  • Add a step using actions/create-github-app-token to generate a GitHub App token based on SEMANTIC_RELEASE_APP_ID and SEMANTIC_RELEASE_PK secrets.
  • Expose the generated GitHub App token via the app-token step outputs.
  • Update the semantic-release step to use the generated GitHub App token as GH_TOKEN instead of the previous GH_TOKEN secret.
  • Keep checkout with persist-credentials: false to ensure semantic-release uses the provided token rather than the default workflow token.
.github/workflows/semantic-release.yml
Reorder and adjust workflow steps to cancel previous runs earlier in the job.
  • Move the workflow-run-cleanup-action step to run before checkout so previous runs are cancelled as early as possible.
  • Ensure cleanup continues to use the default GITHUB_TOKEN secret for authorization.
.github/workflows/semantic-release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Contributor

SC Environment Impact Assessment

Overall Impact:NONE

No SC Environment-specific impacts detected in this PR.

What was checked

This PR was automatically scanned for:

  • Database migrations
  • ClowdApp configuration changes
  • Kessel integration changes
  • AWS service integrations (S3, RDS, ElastiCache)
  • Kafka topic changes
  • Secrets management changes
  • External dependencies

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider pinning rokroskar/workflow-run-cleanup-action to a specific tag or commit SHA instead of @master to reduce supply-chain risk in the workflow.
  • Since you are already touching this workflow, it may be a good moment to upgrade actions/checkout@v2 and actions/setup-python@v2 to their latest stable major versions to benefit from security and performance improvements.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider pinning `rokroskar/workflow-run-cleanup-action` to a specific tag or commit SHA instead of `@master` to reduce supply-chain risk in the workflow.
- Since you are already touching this workflow, it may be a good moment to upgrade `actions/checkout@v2` and `actions/setup-python@v2` to their latest stable major versions to benefit from security and performance improvements.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jdobes jdobes force-pushed the semantic_release_gh_app branch from 2d62bd3 to ee94963 Compare March 13, 2026 16:07
@jdobes jdobes merged commit 38700ac into RedHatInsights:master Mar 13, 2026
12 of 13 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