You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,16 @@ npm run package
38
38
npm test
39
39
```
40
40
41
+
## Validation
42
+
43
+
The action uses [Zod](https://zod.dev/) for schema validation, automatically validating code.json in two scenarios:
44
+
45
+
### 1. Before Generation
46
+
Every time the action generates or updates code.json (via schedule or workflow_dispatch), it validates the output before creating a PR or pushing. If validation fails, no changes are made.
47
+
48
+
### 2. On PR Edits
49
+
When the `pull_request` trigger is configured, the action validates code.json whenever it's edited in a PR. This ensures users cannot accidentally merge invalid JSON.
50
+
41
51
### Workflow and Branching
42
52
43
53
We follow the [GitHub Flow Workflow](https://guides.github.com/introduction/flow/):
Copy file name to clipboardExpand all lines: README.md
+36-11Lines changed: 36 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,26 +33,33 @@ ADMIN_TOKEN:
33
33
```yaml
34
34
updated:
35
35
description: "Boolean indicating whether code.json was updated"
36
+
36
37
pr_url:
37
38
description: "URL of the created pull request if changes were made via PR"
39
+
38
40
commit_sha:
39
41
description: "SHA of the commit if pushed directly to branch"
42
+
40
43
method_used:
41
44
description: "Method used for the update: 'direct_push' or 'pull_request'"
42
45
```
43
46
44
47
## Workflow Examples
45
48
46
-
### Option 1: Direct Push
49
+
### Option 1: Direct Push
47
50
48
-
This approach tries to push directly to the branch using a Personal Access Token, but falls back to creating a pull request if the direct push fails.
51
+
This approach tries to push directly to the branch using a Personal Access Token, but falls back to creating a pull request if the direct push fails. When users need to edit code.json, they should create a PR which will automatically validate their changes.
49
52
50
53
```yaml
51
-
name: Update Code.json (Smart Mode)
54
+
name: Update Code.json
52
55
on:
53
56
schedule:
54
57
- cron: 0 0 1 * * # First day of every month
55
58
workflow_dispatch:
59
+
pull_request:
60
+
types: [opened, synchronize]
61
+
paths:
62
+
- 'code.json'
56
63
57
64
permissions:
58
65
contents: write
@@ -89,14 +96,18 @@ jobs:
89
96
90
97
### Option 2: Pull Request Only
91
98
92
-
This approach always creates a pull request, ensuring code review for all changes.
99
+
This approach always creates a pull request for both automatic generation and validation of manual edits, ensuring code review for all changes.
93
100
94
101
```yaml
95
102
name: Update Code.json
96
103
on:
97
104
schedule:
98
105
- cron: 0 0 1 * * # First day of every month
99
106
workflow_dispatch:
107
+
pull_request:
108
+
types: [opened, synchronize]
109
+
paths:
110
+
- 'code.json'
100
111
101
112
permissions:
102
113
contents: write
@@ -113,13 +124,27 @@ jobs:
113
124
fetch-depth: 0
114
125
115
126
- name: Update code.json
116
-
uses: DSACMS/automated-codejson-generator@latest
127
+
uses: DSACMS/automated-codejson-generator@v1.2.0
117
128
with:
118
129
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119
130
BRANCH: "main"
120
131
SKIP_PR: "false"
121
132
```
122
133
134
+
### How It Works
135
+
136
+
**Automatic Generation**
137
+
- The action calculates metadata, validates it, and creates a PR or pushes directly
138
+
- Validation ensures only valid code.json is created
139
+
- Users can then fill in manual fields by editing the PR
140
+
141
+
**PR Validation**
142
+
- When users edit code.json in a PR, validation runs automatically on every commit
143
+
- The PR cannot be merged if validation fails (when branch protection is enabled)
144
+
- Error messages help users fix issues quickly
145
+
146
+
**Important:** For direct push mode, users should always create PRs when manually editing code.json to ensure validation runs. Direct edits to the main branch will not be validated by this action.
147
+
123
148
## Setting Up Personal Access Token (PAT)
124
149
125
150
To use the direct push functionality, you'll need to create a Personal Access Token:
@@ -128,14 +153,14 @@ To use the direct push functionality, you'll need to create a Personal Access To
128
153
129
154
1. **Go to GitHub Settings**: Navigate to your GitHub account settings
130
155
2. **Developer Settings**: Click on "Developer settings" in the left sidebar
131
-
3. **Personal Access Tokens**: Choose "Tokens (classic)" or "Fine-grained tokens"
0 commit comments