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: README.md
+97-6Lines changed: 97 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,28 @@ A GitHub Action that automatically generates and maintains code.json files for f
4
4
5
5
## About the Project
6
6
7
-
This project provides a GitHub Action that helps federal agencies maintain their code.json files, which are required for compliance with the Federal Source Code Policy. The action automatically calculates and updates various metadata fields including labor hours, programming languages used, repository information, and timestamps. It creates pull requests with these updates, making it easier to keep code.json files accurate and up-to-date.
7
+
This project provides a GitHub Action that helps federal agencies maintain their code.json files, which are required for compliance with the Federal Source Code Policy. The action automatically calculates and updates various metadata fields including labor hours, programming languages used, repository information, and timestamps. It can either create pull requests or push directly to branches (with appropriate permissions), making it easier to keep code.json files accurate and up-to-date.
8
8
9
9
## Inputs
10
10
11
11
```yaml
12
12
GITHUB_TOKEN:
13
-
description: "GitHub token used for API access"
13
+
description: "GitHub token used for API access and PR creation"
14
14
required: true
15
15
default: ${{ github.token }}
16
+
17
+
BRANCH:
18
+
description: "Name of the branch to update"
19
+
required: false
20
+
21
+
SKIP_PR:
22
+
description: "Try to push directly to branch first, fallback to PR if it fails. Requires ADMIN_TOKEN."
23
+
required: false
24
+
default: "false"
25
+
26
+
ADMIN_TOKEN:
27
+
description: "Personal Access Token with admin/write privileges for direct push. Required when SKIP_PR is true."
28
+
required: false
16
29
```
17
30
18
31
## Outputs
@@ -21,12 +34,62 @@ GITHUB_TOKEN:
21
34
updated:
22
35
description: "Boolean indicating whether code.json was updated"
23
36
pr_url:
24
-
description: "URL of the created pull request if changes were made"
37
+
description: "URL of the created pull request if changes were made via PR"
38
+
commit_sha:
39
+
description: "SHA of the commit if pushed directly to branch"
40
+
method_used:
41
+
description: "Method used for the update: 'direct_push' or 'pull_request'"
25
42
```
26
43
27
44
## Workflow Examples
28
45
29
-
### Create a PR to add compliant code.json
46
+
### Option 1: Direct Push
47
+
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.
49
+
50
+
```yaml
51
+
name: Update Code.json (Smart Mode)
52
+
on:
53
+
schedule:
54
+
- cron: 0 0 1 * * # First day of every month
55
+
workflow_dispatch:
56
+
57
+
permissions:
58
+
contents: write
59
+
pull-requests: write
60
+
issues: write
61
+
62
+
jobs:
63
+
update-code-json:
64
+
runs-on: ubuntu-latest
65
+
steps:
66
+
- name: Checkout Repository
67
+
uses: actions/checkout@v4
68
+
with:
69
+
fetch-depth: 0
70
+
71
+
- name: Update code.json
72
+
id: update
73
+
uses: DSACMS/automated-codejson-generator@v1.2.0
74
+
with:
75
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76
+
ADMIN_TOKEN: ${{ secrets.ADMIN_PAT }} # PAT with admin/push permissions
0 commit comments