-
Notifications
You must be signed in to change notification settings - Fork 16
Migrate to reusable danger workflows from ruby-grape-danger #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dce7b74
8fff15c
8ee3d0f
2916013
4439e2f
734bfc9
70ccc9f
55a646b
99fbc1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,33 +3,9 @@ on: | |||||
| workflow_run: | ||||||
| workflows: [Danger] | ||||||
| types: [completed] | ||||||
|
|
||||||
| permissions: | ||||||
| actions: read | ||||||
| contents: read | ||||||
| issues: write | ||||||
| pull-requests: write | ||||||
| workflow_call: | ||||||
|
|
||||||
| jobs: | ||||||
| comment: | ||||||
| runs-on: ubuntu-latest | ||||||
| if: github.event.workflow_run.event == 'pull_request' | ||||||
| steps: | ||||||
| - name: Checkout | ||||||
| uses: actions/checkout@v4 | ||||||
| with: | ||||||
| fetch-depth: 1 | ||||||
| - name: Download Danger Report | ||||||
| uses: actions/download-artifact@v4 | ||||||
| continue-on-error: true | ||||||
| with: | ||||||
| name: danger-report | ||||||
| run-id: ${{ github.event.workflow_run.id }} | ||||||
| repository: ${{ github.event.workflow_run.repository.full_name }} | ||||||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||||||
| - name: Post or Update PR Comment | ||||||
| uses: actions/github-script@v7 | ||||||
| with: | ||||||
| script: | | ||||||
| const script = require('./.github/scripts/post-danger-comment.js'); | ||||||
| await script({ github, context, core }); | ||||||
| uses: ruby-grape/danger/.github/workflows/danger-comment.yml@report-workflows | ||||||
|
||||||
| uses: ruby-grape/danger/.github/workflows/danger-comment.yml@report-workflows | |
| uses: ruby-grape/danger/.github/workflows/danger-comment.yml@main |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,31 +2,9 @@ name: Danger | |||||||
| on: | ||||||||
| pull_request: | ||||||||
| types: [ opened, reopened, edited, synchronize ] | ||||||||
|
||||||||
| types: [ opened, reopened, edited, synchronize ] | |
| types: [ opened, reopened, edited, synchronize ] | |
| # Expose this workflow so it can be invoked by other workflows via `workflow_call` (current or future use). |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow references a specific branch (@report-workflows) of the reusable workflow. While this is appropriate for testing during development, consider updating this to reference a stable version tag or the main branch once the ruby-grape-danger repository's report-workflows branch is merged and released. Using branch references can lead to unexpected changes if the upstream branch is modified.
| uses: ruby-grape/danger/.github/workflows/danger-run.yml@report-workflows | |
| uses: ruby-grape/danger/.github/workflows/danger-run.yml@main |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,30 +1,6 @@ | ||||||||
| # danger.systems | ||||||||
|
|
||||||||
| toc.check! | ||||||||
| changelog.check! | ||||||||
|
|
||||||||
| # Export report for danger-comment workflow | ||||||||
| require 'json' | ||||||||
| event_path = ENV.fetch('GITHUB_EVENT_PATH', nil) | ||||||||
| report_path = ENV.fetch('DANGER_REPORT_PATH', nil) | ||||||||
| if report_path && event_path && File.exist?(event_path) | ||||||||
| event = JSON.parse(File.read(event_path)) | ||||||||
| pr_number = event.dig('pull_request', 'number') | ||||||||
| if pr_number | ||||||||
| to_messages = lambda do |items| | ||||||||
| Array(items).map do |item| | ||||||||
| item.respond_to?(:message) ? item.message : item.to_s | ||||||||
| end | ||||||||
| end | ||||||||
| # Import ruby-grape-danger for automatic danger report export | ||||||||
| danger.import_dangerfile(gem: 'ruby-grape-danger') | ||||||||
|
|
||||||||
| report = { | ||||||||
| pr_number: pr_number, | ||||||||
| errors: to_messages.call(status_report[:errors]), | ||||||||
| warnings: to_messages.call(status_report[:warnings]), | ||||||||
| messages: to_messages.call(status_report[:messages]), | ||||||||
| markdowns: to_messages.call(status_report[:markdowns]) | ||||||||
| } | ||||||||
|
|
||||||||
| File.write(report_path, JSON.pretty_generate(report)) | ||||||||
| end | ||||||||
| end | ||||||||
| changelog.check! | ||||||||
|
||||||||
| changelog.check! | |
| changelog.check! | |
| toc.check! |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,5 +15,6 @@ group :development, :test do | |||||
| gem 'rubocop', '~> 1.63.1' | ||||||
| gem 'rubocop-rake' | ||||||
| gem 'rubocop-rspec' | ||||||
| gem 'ruby-grape-danger' | ||||||
|
||||||
| gem 'ruby-grape-danger' | |
| gem 'ruby-grape-danger', git: 'https://github.com/ruby-grape/danger', branch: 'report-workflows' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
workflow_calltrigger has been added, but this workflow doesn't appear to be called by any other workflows in the repository based on the PR changes. If this trigger is intended for future use or external calls, consider adding a comment explaining its purpose. Otherwise, it may be unnecessary and could be removed to keep the configuration minimal.