danger-pr-comment 0.1.0 → 0.1.1

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: ac924e732e1c8df10638ac0e603fd82deacd4f0a3f190c40147908bd07fcb9ab
4
+ data.tar.gz: 8fe5fdadc336e663248022ea2a5ad150bb7101ed4d9b5a5f24ef8fbed0278509
5
5
  SHA512:
6
- metadata.gz: bf4f9f6a348f7ab8bcd42f5827a9c018e4a75fa12f3606613363bb6dfbc1983f9d8e9a1b4db36a06ece3f1bd4d5b232acf867d6f01699a31f7e56358cfa558a5
7
- data.tar.gz: 15634bc538e51a3c634839bc36efb31fd5f37c960e7e97cc8c353ca7a55d1fdb5b52b04eb2048326303e27a573eff34dcf10578715e9a2b31b278acf6ddd53f9
6
+ metadata.gz: 7a4a9505d2a5659cc08cc7ec60d8a6d5383b539915b041057199c299bbe17bf43a052d83300ebeb88499b72789ec934d36519974a103cedf3b23e6c9e177a029
7
+ data.tar.gz: 4c7615bebc46bb91024bd78b628bade8a919247817462ba4ff1a207260fe45f335cfe34fac5a58626ef0c0a70c10a77ffaf377751045fe5a7e49481c61e5c7d3
data/README.md CHANGED
@@ -1,9 +1,57 @@
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
+
3
5
  Reusable GitHub Actions workflows for running Danger and posting a PR comment from a JSON report.
4
6
 
7
+ ## Table of Contents
8
+
9
+ - [Usage](#usage)
10
+ - [Prerequisites](#prerequisites)
11
+ - [Quick Install](#quick-install)
12
+ - [Manual Setup](#manual-setup)
13
+ - [Implementation Details](#implementation-details)
14
+ - [JSON Report Output](#json-report-output)
15
+ - [Shared Dangerfile](#shared-dangerfile)
16
+ - [Custom at_exit Hook](#custom-at_exit-hook)
17
+ - [Permissions](#permissions)
18
+ - [Inputs](#inputs)
19
+ - [danger-run.yml](#danger-runyml)
20
+ - [danger-comment.yml](#danger-commentyml)
21
+ - [License](#license)
22
+
5
23
  ## Usage
6
24
 
25
+ ### Prerequisites
26
+
27
+ Setup [Danger](https://github.com/danger/danger) in your repository.
28
+
29
+ For example, the following `Gemfile` and `Dangerfile` install danger with the [danger-changelog plugin](https://github.com/dblock/danger-changelog).
30
+
31
+ ```ruby
32
+ group :development, :test do
33
+ gem 'danger'
34
+ gem 'danger-changelog'
35
+ gem 'danger-pr-comment', require: false
36
+ end
37
+ ```
38
+
39
+ ```
40
+ # frozen_string_literal: true
41
+
42
+ danger.import_dangerfile(gem: 'danger-pr-comment')
43
+
44
+ changelog.check!
45
+ ```
46
+
47
+ Run `bundle install` and `bundle exec danger` to make sure it works.
48
+
49
+ ```bash
50
+ bundle exec danger
51
+
52
+ Could not find the type of CI for Danger to run on.
53
+ ```
54
+
7
55
  ### Quick Install
8
56
 
9
57
  From your repository root:
@@ -12,7 +60,13 @@ From your repository root:
12
60
  curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash
13
61
  ```
14
62
 
15
- Use `--force` to overwrite existing workflow files. To target a specific directory:
63
+ Use `--force` to overwrite existing workflow files `.github/workflows/danger.yml` and `.github/workflows/danger-comment.yml`:
64
+
65
+ ```bash
66
+ curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash -s -- --force
67
+ ```
68
+
69
+ To target a specific directory:
16
70
 
17
71
  ```bash
18
72
  curl -fsSL https://raw.githubusercontent.com/numbata/danger-pr-comment/main/scripts/install-workflows.sh | bash -s -- --root /path/to/repo
@@ -30,8 +84,11 @@ on:
30
84
 
31
85
  jobs:
32
86
  danger:
33
- uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@main
87
+ uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.1
34
88
  secrets: inherit
89
+ with:
90
+ ruby-version: '3.4'
91
+ bundler-cache: true
35
92
  ```
36
93
 
37
94
  Create `.github/workflows/danger-comment.yml` in your repository:
@@ -43,34 +100,35 @@ on:
43
100
  workflows: [Danger]
44
101
  types: [completed]
45
102
 
103
+ permissions:
104
+ actions: read # download artifacts
105
+ issues: write # list + create/update comments
106
+ pull-requests: write # PR comment access
107
+
46
108
  jobs:
47
109
  comment:
48
- uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@main
110
+ uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.1
49
111
  secrets: inherit
50
112
  ```
51
113
 
52
- ## Requirements
114
+ ## Implementation Details
53
115
 
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.
116
+ 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
117
 
58
- ### Dangerfile report example
118
+ ### JSON Report Output
59
119
 
60
- If you want a shared Dangerfile, add the gem and import it:
120
+ Your Dangerfile must write a JSON report to `ENV['DANGER_REPORT_PATH']`.
61
121
 
62
- ```ruby
63
- # Gemfile
64
- gem 'danger-pr-comment', require: false
65
- ```
122
+ #### Shared Dangerfile
66
123
 
67
124
  ```ruby
68
- # Dangerfile
69
- # Import danger-pr-comment for automatic danger report export
125
+ # Import danger-pr-comment for automatic danger report export to JSON
70
126
  danger.import_dangerfile(gem: 'danger-pr-comment')
71
127
  ```
72
128
 
73
- Or add this to your project's `Dangerfile` (or a shared Dangerfile) to emit the JSON report yourself:
129
+ See [Dangerfile](Dangerfile) for implementation details.
130
+
131
+ #### Custom `at_exit` Hook
74
132
 
75
133
  ```ruby
76
134
  # Dangerfile
@@ -106,9 +164,13 @@ at_exit do
106
164
  end
107
165
  ```
108
166
 
109
- ## Inputs
167
+ ### Permissions
168
+
169
+ 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).
170
+
171
+ ### Inputs
110
172
 
111
- `danger-run.yml` inputs:
173
+ #### `danger-run.yml`
112
174
 
113
175
  - `ruby-version`: Ruby version for `ruby/setup-ruby`. Leave empty to use `.ruby-version`/`.tool-versions`.
114
176
  - `bundler-cache`: Enable Bundler caching (default `true`).
@@ -116,7 +178,7 @@ end
116
178
  - `report-artifact-name`: Artifact name for the report (default `danger-report`).
117
179
  - `report-file`: Report filename (default `danger-report.json`).
118
180
 
119
- `danger-comment.yml` inputs:
181
+ #### `danger-comment.yml`
120
182
 
121
183
  - `report-artifact-name`: Artifact name to download (default `danger-report`).
122
184
  - `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.1.1'
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.1.1
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-10-21 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: []