1
+ name : " Repository Hygiene Check"
2
+ on :
3
+ push :
4
+ branches :
5
+ - ' main'
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ check-first-run :
10
+ name : Check For First Run
11
+ runs-on : ubuntu-latest
12
+ outputs :
13
+ should_run : ${{ steps.check.outputs.should_run }}
14
+ permissions :
15
+ contents : read
16
+ pull-requests : write
17
+ steps :
18
+ - uses : actions/checkout@v4
19
+ - id : check
20
+ run : |
21
+ # If manually triggered, always run
22
+
23
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
24
+ echo "should_run=true" >> $GITHUB_OUTPUT
25
+ exit 0
26
+
27
+ fi
28
+
29
+ # Check if initialization label exists
30
+
31
+ has_label=$(gh label list --json name | jq '.[] | select(.name=="repolinter-initialized")')
32
+
33
+ if [[ -z "$has_label" ]]; then
34
+ # First time - create label and allow run
35
+ gh label create repolinter-initialized --description "Marks repo as having run initial repolinter check"
36
+ echo "should_run=true" >> $GITHUB_OUTPUT
37
+ else
38
+ echo "should_run=false" >> $GITHUB_OUTPUT
39
+
40
+ fi
41
+ env :
42
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43
+
44
+ resolve-repolinter-json :
45
+ name : Get Repolinter Config
46
+ needs : check-first-run
47
+ if : needs.check-first-run.outputs.should_run == 'true'
48
+ uses : DSACMS/repo-scaffolder/.github/workflows/extendJSONFile.yml@main
49
+ with :
50
+ url_to_json : ' https://raw.githubusercontent.com/DSACMS/repo-scaffolder/main/tier3/%7B%7Bcookiecutter.project_slug%7D%7D/repolinter.json'
51
+
52
+ repolinter-checks :
53
+ name : Tier 3 Checks
54
+ needs : [check-first-run, resolve-repolinter-json]
55
+ if : needs.check-first-run.outputs.should_run == 'true'
56
+ runs-on : ubuntu-latest
57
+ permissions :
58
+ contents : write
59
+ pull-requests : write
60
+ env :
61
+ RAW_JSON : ${{ needs.resolve-repolinter-json.outputs.raw-json }}
62
+ steps :
63
+ - uses : actions/checkout@v4
64
+ - run : echo $RAW_JSON > repolinter.json
65
+ - uses : DSACMS/repolinter-action@main
66
+ with :
67
+ config_file : ' repolinter.json'
68
+ output_type : ' pull-request'
69
+ pull_request_labels : ' repolinter-initialized, cms-oss, cms-gov'
70
+ token : ${{ secrets.REPOLINTER_AUTO_TOKEN }}
0 commit comments