@@ -2,9 +2,9 @@ name: Pull Request
2
2
3
3
on :
4
4
pull_request :
5
- types : [' synchronize', ' opened', ' reopened', ' ready_for_review' ]
5
+ types : [" synchronize", " opened", " reopened", " ready_for_review" ]
6
6
branches :
7
- - main
7
+ - main
8
8
9
9
env :
10
10
DB_VERSION : 1.0.0
@@ -21,58 +21,117 @@ jobs:
21
21
shell : bash
22
22
if : ${{ !github.event.pull_request.draft }}
23
23
steps :
24
- # If the condition above is not met, aka, the PR is not in draft status, then this step is skipped.
25
- # Because this step is part of the critical path, omission of this step will result in remaining CI steps not gettinge executed.
26
- # As of 8/8/2022 there is now way to enforce this beahvior in GitHub Actions CI.
24
+ # If the condition above is not met, aka, the PR is not in draft status, then this step is skipped.
25
+ # Because this step is part of the critical path, omission of this step will result in remaining CI steps not gettinge executed.
26
+ # As of 8/8/2022 there is now way to enforce this beahvior in GitHub Actions CI.
27
27
- run : exit 0
28
28
29
29
Docker :
30
30
needs : [run-ci]
31
31
runs-on : ubuntu-latest
32
32
steps :
33
- - name : Checkout
34
- uses : actions/checkout@v3
33
+ - name : Checkout
34
+ uses : actions/checkout@v4
35
35
36
- - uses : actions/setup-go@v3.1.0
37
- with :
38
- go-version : ' 1.20 '
39
- check-latest : true
36
+ - uses : actions/setup-go@v5
37
+ with :
38
+ go-version : " 1.21 "
39
+ check-latest : true
40
40
41
- - name : Build
42
- run : |
43
- docker system prune -a -f
44
- docker build --no-cache -t api-server:test .
41
+ - name : Build
42
+ run : |
43
+ docker system prune -a -f
44
+ docker build --no-cache -t api-server:test .
45
45
46
46
Linting :
47
47
needs : [run-ci]
48
48
runs-on : ubuntu-latest
49
49
steps :
50
- - name : Checkout
51
- uses : actions/checkout@v3
50
+ - name : Checkout
51
+ uses : actions/checkout@v4
52
52
53
- - uses : actions/setup-go@v3.1.0
54
- with :
55
- go-version : ' 1.20 '
56
- check-latest : true
53
+ - uses : actions/setup-go@v5
54
+ with :
55
+ go-version : " 1.21 "
56
+ check-latest : true
57
57
58
- - name : Lint Internal Package
59
-
60
- with :
61
- args : --verbose --timeout 5m
58
+ - name : Lint Internal Package
59
+
60
+ with :
61
+ args : --verbose --timeout 5m
62
62
63
- API-Test :
63
+ Tests :
64
64
runs-on : ubuntu-latest
65
65
needs : [run-ci]
66
+ permissions :
67
+ contents : write
68
+ pull-requests : write
66
69
steps :
67
- - name : Checkout
68
- uses : actions/checkout@v3
70
+ - name : Retrieve Credentials
71
+ id : import-secrets
72
+ uses : hashicorp/vault-action@v2
73
+ with :
74
+ url : https://vault.prism.spectrocloud.com
75
+ method : approle
76
+ roleId : ${{ secrets.VAULT_ROLE_ID }}
77
+ secretId : ${{ secrets.VAULT_SECRET_ID }}
78
+ secrets : /providers/github/organizations/spectrocloud/token?org_name=spectrocloud token | VAULT_GITHUB_TOKEN
79
+
80
+ - name : Checkout
81
+ uses : actions/checkout@v4
82
+ with :
83
+ ref : ${{ github.head_ref }}
84
+ fetch-depth : 0
85
+ token : ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
86
+
87
+ - name : Setup Nodejs
88
+ uses : actions/setup-node@v3
89
+ with :
90
+ node-version : 18
91
+
92
+ - name : Install Dependencies
93
+ run : make tests
94
+
95
+ - name : Go Coverage Badge
96
+ uses : tj-actions/coverage-badge-go@v2
97
+ with :
98
+ filename : coverage.out
99
+
100
+ - name : Verify Changed files
101
+ uses : tj-actions/verify-changed-files@v18
102
+ id : verify-changed-files
103
+ with :
104
+ files : README.md
69
105
70
- - name : Setup Nodejs
71
- uses : actions/setup-node@v3
72
- with :
73
- node-version : 18
106
+ - name : Commit changes
107
+ if : steps.verify-changed-files.outputs.files_changed == 'true'
108
+ run : |
109
+ git config --local user.email "[email protected] "
110
+ git config --local user.name "GitHub Action"
111
+ git add README.md
112
+ git commit -m "chore: Updated coverage badge."
113
+
114
+ - name : Push changes
115
+ if : steps.verify-changed-files.outputs.files_changed == 'true'
116
+ uses : ad-m/github-push-action@master
117
+ with :
118
+ github_token : ${{ steps.import-secrets.outputs.VAULT_GITHUB_TOKEN }}
119
+ branch : ${{ github.GITHUB_REF }} # This also worked with GITHUB_BASE_REF
120
+ repository : ${{ github.repository }}
121
+ force_with_lease : true
122
+
123
+ API-Test :
124
+ runs-on : ubuntu-latest
125
+ needs : [run-ci]
126
+ steps :
127
+ - name : Checkout
128
+ uses : actions/checkout@v4
74
129
75
- - name : API Test
76
- run : |
77
- make ci-tests
130
+ - uses : actions/setup-go@v5
131
+ with :
132
+ go-version : " 1.21"
133
+ check-latest : true
78
134
135
+ - name : API Test
136
+ run : |
137
+ make ci-tests
0 commit comments