Skip to content

Conversation

@numbata
Copy link
Contributor

@numbata numbata commented Dec 7, 2025

Switch to tokenless execution using with GitHub Actions annotations for inline feedback. This eliminates the need for the grape-bot token while still providing PR feedback via workflow annotations.

Changes:

  • Use commit SHAs instead of branch refs for reliable diff calculation
  • Output violations as GitHub Actions annotations (errors, warnings, notices)
  • Update to actions/checkout@v6 with full history fetch

@numbata numbata force-pushed the fix_danger_workflow branch 2 times, most recently from d2c8786 to 01e0ede Compare December 7, 2025 00:47
Use secure two-workflow pattern from dblock's blog post:
- First workflow runs on pull_request, executes danger dry_run
  without write permissions, uploads JSON report as artifact
- Second workflow runs on workflow_run after first completes,
  downloads artifact and posts PR comment with write access

This is secure because untrusted fork code never has access to
write permissions. The comment workflow runs trusted code from
the base branch.

Inlined Dangerfile checks from ruby-grape-danger to avoid plugins
that require GitHub API methods not available in dry_run mode.
@numbata numbata force-pushed the fix_danger_workflow branch from 360835e to f7113a2 Compare December 7, 2025 01:36
Apply Style/IfUnlessModifier and Performance/RegexpMatch fixes.
Disable Style/SignalException for Danger's `fail` DSL method.
For fork PRs, github.event.workflow_run.pull_requests is always
empty due to GitHub security restrictions. Include PR number in
the danger_report.json artifact instead.
@numbata numbata force-pushed the fix_danger_workflow branch from d7dc3d5 to eb222e4 Compare December 7, 2025 02:36
# frozen_string_literal: true

danger.import_dangerfile(gem: 'ruby-grape-danger')
# Inline checks from ruby-grape-danger (avoids plugins requiring GitHub API token)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this, ofc, should be moved to the https://github.com/ruby-grape/danger/blob/master/Dangerfile

message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false) if !has_app_changes && has_spec_changes

# Simplified changelog check (replaces danger-changelog plugin which requires github.* methods)
# Note: toc.check! from danger-toc plugin removed (not essential for CI)
Copy link
Contributor Author

@numbata numbata Dec 7, 2025

Choose a reason for hiding this comment

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

- Add explicit PR event types (opened, synchronize, reopened)
- Set artifact retention to 1 day
- Fix regex patterns with word boundaries to avoid false positives
@numbata numbata force-pushed the fix_danger_workflow branch from 8228003 to 8c59d3e Compare December 7, 2025 02:42
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.

1 participant