danger-pr-comment 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bed333a43c4c6883fbeea22eb24a5b1e7f92a3232fc446dfe0103b044c7b7579
4
- data.tar.gz: 10e13269a7c517aa0f6539c728f5e6428960e1200e2577f4e58bdfa049f76d08
3
+ metadata.gz: de6fd12eff6b5af93d1579abee28098cdff6fe5794a7d882da84c3b016a29c64
4
+ data.tar.gz: 7890bfb7f03ffc3c2864036aeb166c76acb6251d44e6bbe16f85290ef63fdea8
5
5
  SHA512:
6
- metadata.gz: bf4f9f6a348f7ab8bcd42f5827a9c018e4a75fa12f3606613363bb6dfbc1983f9d8e9a1b4db36a06ece3f1bd4d5b232acf867d6f01699a31f7e56358cfa558a5
7
- data.tar.gz: 15634bc538e51a3c634839bc36efb31fd5f37c960e7e97cc8c353ca7a55d1fdb5b52b04eb2048326303e27a573eff34dcf10578715e9a2b31b278acf6ddd53f9
6
+ metadata.gz: d5037077891ab80b8781b19ff9549db35193a1a5f9dd1085fc422c6ffcfe07156bd853ecca15ca985c2dbe113db950d4e46bdebdfe3dbd7c2c719d06e5bff4ed
7
+ data.tar.gz: 24d557d9eadd868de0069886ca5187cb729b0a0c5e2d2238003a56f50432eabf386b6f7f5693cec63081a9e24bd0a4a777c47b9df559dd9508ba36d6fc048239
data/README.md CHANGED
@@ -1,9 +1,58 @@
1
1
  # Danger PR Comment
2
2
 
3
+ [![Test](https://github.com/numbata/danger-pr-comment/actions/workflows/test.yml/badge.svg)](https://github.com/numbata/danger-pr-comment/actions/workflows/test.yml)
4
+ [![Coverage Status](https://coveralls.io/repos/github/numbata/danger-pr-comment/badge.svg?branch=main)](https://coveralls.io/github/numbata/danger-pr-comment?branch=main)
5
+
3
6
  Reusable GitHub Actions workflows for running Danger and posting a PR comment from a JSON report.
4
7
 
8
+ ## Table of Contents
9
+
10
+ - [Usage](#usage)
11
+ - [Prerequisites](#prerequisites)
12
+ - [Quick Install](#quick-install)
13
+ - [Manual Setup](#manual-setup)
14
+ - [Implementation Details](#implementation-details)
15
+ - [JSON Report Output](#json-report-output)
16
+ - [Shared Dangerfile](#shared-dangerfile)
17
+ - [Custom at_exit Hook](#custom-at_exit-hook)
18
+ - [Permissions](#permissions)
19
+ - [Inputs](#inputs)
20
+ - [danger-run.yml](#danger-runyml)
21
+ - [danger-comment.yml](#danger-commentyml)
22
+ - [License](#license)
23
+
5
24
  ## Usage
6
25
 
26
+ ### Prerequisites
27
+
28
+ Setup [Danger](https://github.com/danger/danger) in your repository.
29
+
30
+ For example, the following `Gemfile` and `Dangerfile` install danger with the [danger-changelog plugin](https://github.com/dblock/danger-changelog).
31
+
32
+ ```ruby
33
+ group :development, :test do
34
+ gem 'danger'
35
+ gem 'danger-changelog'
36
+ gem 'danger-pr-comment', require: false
37
+ end
38
+ ```
39
+
40
+ ```
41
+ # frozen_string_literal: true
42
+
43
+ danger.import_dangerfile(gem: 'danger-pr-comment')
44
+
45
+ changelog.check!
46
+ ```
47
+
48
+ Run `bundle install` and `bundle exec danger` to make sure it works.
49
+
50
+ ```bash
51
+ bundle exec danger
52
+
53
+ Could not find the type of CI for Danger to run on.
54
+ ```
55
+
7
56
  ### Quick Install
8
57
 
9
58
  From your repository root:
@@ -12,7 +61,13 @@ From your repository root:
12
61
  curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash
13
62
  ```
14
63
 
15
- Use `--force` to overwrite existing workflow files. To target a specific directory:
64
+ Use `--force` to overwrite existing workflow files `.github/workflows/danger.yml` and `.github/workflows/danger-comment.yml`:
65
+
66
+ ```bash
67
+ curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash -s -- --force
68
+ ```
69
+
70
+ To target a specific directory:
16
71
 
17
72
  ```bash
18
73
  curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash -s -- --root /path/to/repo
@@ -30,8 +85,11 @@ on:
30
85
 
31
86
  jobs:
32
87
  danger:
33
- uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@main
88
+ uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.2.0
34
89
  secrets: inherit
90
+ with:
91
+ ruby-version: '3.4'
92
+ bundler-cache: true
35
93
  ```
36
94
 
37
95
  Create `.github/workflows/danger-comment.yml` in your repository:
@@ -43,34 +101,35 @@ on:
43
101
  workflows: [Danger]
44
102
  types: [completed]
45
103
 
104
+ permissions:
105
+ actions: read # download artifacts
106
+ issues: write # list + create/update comments
107
+ pull-requests: write # PR comment access
108
+
46
109
  jobs:
47
110
  comment:
48
- uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@main
111
+ uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.2.0
49
112
  secrets: inherit
50
113
  ```
51
114
 
52
- ## Requirements
115
+ ## Implementation Details
53
116
 
54
- - Your repository must run `bundle exec danger` successfully.
55
- - Your Dangerfile must write a JSON report to `ENV['DANGER_REPORT_PATH']` (for example, via a custom `at_exit` hook or a shared Dangerfile).
56
- - The `Danger Comment` workflow needs `actions: read` and `issues: write` permissions to download artifacts and post comments.
117
+ Using danger-pr-comment solves the problem of needing special permissions to post a PR comment from contributions from forks. This is implemented by producing a JSON report during the PR, and reading the report in a separate workflow.
57
118
 
58
- ### Dangerfile report example
119
+ ### JSON Report Output
59
120
 
60
- If you want a shared Dangerfile, add the gem and import it:
121
+ Your Dangerfile must write a JSON report to `ENV['DANGER_REPORT_PATH']`.
61
122
 
62
- ```ruby
63
- # Gemfile
64
- gem 'danger-pr-comment', require: false
65
- ```
123
+ #### Shared Dangerfile
66
124
 
67
125
  ```ruby
68
- # Dangerfile
69
- # Import danger-pr-comment for automatic danger report export
126
+ # Import danger-pr-comment for automatic danger report export to JSON
70
127
  danger.import_dangerfile(gem: 'danger-pr-comment')
71
128
  ```
72
129
 
73
- Or add this to your project's `Dangerfile` (or a shared Dangerfile) to emit the JSON report yourself:
130
+ See [Dangerfile](Dangerfile) for implementation details.
131
+
132
+ #### Custom `at_exit` Hook
74
133
 
75
134
  ```ruby
76
135
  # Dangerfile
@@ -106,17 +165,22 @@ at_exit do
106
165
  end
107
166
  ```
108
167
 
109
- ## Inputs
168
+ ### Permissions
169
+
170
+ The `Danger Comment` workflow requires explicit permissions. Reusable workflows cannot grant permissions to their callers. Required: `actions: read` (download artifacts from the Danger run), `issues: write` and `pull-requests: write` (create/update PR comments).
171
+
172
+ ### Inputs
110
173
 
111
- `danger-run.yml` inputs:
174
+ #### `danger-run.yml`
112
175
 
113
176
  - `ruby-version`: Ruby version for `ruby/setup-ruby`. Leave empty to use `.ruby-version`/`.tool-versions`.
177
+ - `gemfile`: Gemfile path for Bundler (default `Gemfile`), for example `gemfiles/danger.gemfile`.
114
178
  - `bundler-cache`: Enable Bundler caching (default `true`).
115
179
  - `danger-args`: Arguments passed to `bundle exec danger` (default `dry_run`).
116
180
  - `report-artifact-name`: Artifact name for the report (default `danger-report`).
117
181
  - `report-file`: Report filename (default `danger-report.json`).
118
182
 
119
- `danger-comment.yml` inputs:
183
+ #### `danger-comment.yml`
120
184
 
121
185
  - `report-artifact-name`: Artifact name to download (default `danger-report`).
122
186
  - `report-file`: Report filename inside the artifact (default `danger-report.json`).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DangerPrComment
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-pr-comment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Subbota
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-07 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: danger
@@ -40,7 +41,9 @@ files:
40
41
  homepage: https://github.com/numbata/danger-pr-comment
41
42
  licenses:
42
43
  - MIT
43
- metadata: {}
44
+ metadata:
45
+ rubygems_mfa_required: 'true'
46
+ post_install_message:
44
47
  rdoc_options: []
45
48
  require_paths:
46
49
  - lib
@@ -55,7 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  requirements: []
58
- rubygems_version: 3.6.8
61
+ rubygems_version: 3.5.22
62
+ signing_key:
59
63
  specification_version: 4
60
64
  summary: Reusable workflows and shared Dangerfile for PR comment reporting.
61
65
  test_files: []