@@ -10,10 +10,38 @@ This workflow automatically generates changesets for pull requests. Changesets a
1010
1111The workflow is triggered by:
1212
13- 1 . When a pull request is labeled with 'ready-for-changeset'
13+ 1 . When a pull request is merged to the ` develop ` branch
14142 . Manually via the GitHub Actions UI using the workflow_dispatch event
1515 - Go to Actions > Generate Changeset > Run workflow
1616 - Enter the PR number and click "Run workflow"
17+ - This can be used to generate changesets for:
18+ - PRs that were merged before the workflow was implemented
19+ - PRs where the workflow was skipped or failed
20+ - PRs that need their changeset regenerated
21+
22+ The workflow will:
23+ - Fetch the PR information using the GitHub API
24+ - Generate a changeset based on the PR title, body, and author
25+ - Commit the changeset to the develop branch
26+ - Update or create a release PR if needed
27+
28+ ### Manual Trigger Usage
29+
30+ To manually generate a changeset for a PR:
31+
32+ 1 . Go to the Actions tab in your repository
33+ 2 . Click on the "Generate Changeset" workflow
34+ 3 . Click "Run workflow"
35+ 4 . Enter the PR number in the input field
36+ 5 . Click "Run workflow"
37+
38+ The workflow will:
39+ - Validate that the PR exists
40+ - Extract all necessary information from the PR
41+ - Generate and commit the changeset
42+ - Update or create a release PR
43+
44+ If the PR doesn't exist or can't be accessed, the workflow will fail with an appropriate error message.
1745
1846## Implementation Options
1947
@@ -56,12 +84,14 @@ Breaking changes are detected by:
5684
5785## Workflow Steps
5886
59- 1 . ** Detect PR Merge** : The workflow runs when a PR is merged or when manually triggered.
60- 2 . ** Extract Metadata** : The workflow extracts relevant information from the PR, including title, author, and body.
61- 3 . ** Generate Changeset** : A changeset file is created with the extracted metadata.
62- 4 . ** Commit Changeset** : The changeset is committed to the branch (typically ` develop ` ).
63- 5 . ** Generate Release Notes** : The ` release:notes ` script processes all changesets to create formatted release notes in a temporary file.
64- 6 . ** Update/Create Release PR** : The workflow either updates an existing release PR or creates a new one with the generated release notes.
87+ 1 . ** Debug Event Information** : The workflow first logs important event details for debugging purposes
88+ 2 . ** Generate Changeset** : The main job runs when a PR is merged or manually triggered, and:
89+ - Checks out the code
90+ - Sets up Node.js
91+ - Installs dependencies
92+ - Extracts PR information
93+ - Generates and commits the changeset
94+ - Updates or creates a release PR
6595
6696## Release Notes Generation
6797
@@ -108,29 +138,41 @@ name: Generate Changeset
108138on :
109139 pull_request_target :
110140 types : [closed]
141+ branches :
142+ - develop
111143 workflow_dispatch :
112144 inputs :
113145 pr_number :
114- description : ' Pull Request Number '
146+ description : ' PR number to generate changeset for '
115147 required : true
116148 type : string
117149
118150jobs :
151+ debug-event :
152+ runs-on : ubuntu-latest
153+ if : github.event_name == 'pull_request_target'
154+ steps :
155+ - name : Debug Event
156+ run : |
157+ echo "Event details..."
158+
119159 generate-changeset :
120- if : (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch'
160+ permissions :
161+ contents : write
162+ pull-requests : write
121163 runs-on : ubuntu-latest
164+ needs : [debug-event]
165+ if : (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch'
122166 env :
123167 REPO_URL : " https://github.com/${{ github.repository }}"
124168 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
125169 steps :
126170 # Checkout code
127171 # Setup Node.js
128172 # Install dependencies
129- # Get PR details
173+ # Extract PR information
130174 # Generate changeset
131- # Commit changeset
132- # Generate release notes to temporary file
133- # Check for existing release PR
175+ # Generate release notes
134176 # Update/Create release PR
135177```
136178
@@ -146,8 +188,12 @@ This approach keeps the repository clean while still allowing the workflow to pr
146188
147189## Prerequisites
148190
149- 1 . Create a 'ready-for-changeset' label in your repository
150- 2 . Set up a Personal Access Token (PAT) with the "repo" scope as a repository secret named ` REPO_PAT `
191+ The workflow uses the default ` GITHUB_TOKEN ` secret provided by GitHub Actions, which has the necessary permissions to:
192+ - Read repository contents
193+ - Create and update pull requests
194+ - Commit changes to branches
195+
196+ No additional secrets or tokens need to be configured.
151197
152198## Local Testing
153199
0 commit comments