Skip to content

Commit a811859

Browse files
committed
Refactor CI workflow to use shared common repo
Introduces a setup job to checkout and upload the descope/common repository as an artifact, which is then downloaded and used in subsequent jobs (build, lint, test, security, pack). This change centralizes the use of common scripts, improves workflow efficiency, and removes redundant checkout steps in each job.
1 parent 85c478a commit a811859

File tree

1 file changed

+49
-33
lines changed

1 file changed

+49
-33
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,66 @@ env:
88
GITHUB_TOKEN: ${{ secrets.AUTHZCACHE_TO_COMMON }}
99

1010
jobs:
11+
setup:
12+
name: Setup Common Repository
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout common scripts
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
with:
18+
repository: descope/common
19+
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
20+
path: common-repo
21+
22+
- name: Upload common repo
23+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
24+
with:
25+
name: common-repo
26+
path: common-repo/
27+
retention-days: 1
28+
1129
build:
1230
name: Build
1331
runs-on: ubuntu-latest
32+
needs: setup
1433
env:
1534
GITHUB_TOKEN: ${{ secrets.AUTHZCACHE_TO_COMMON }}
1635
steps:
1736
- name: Checkout code
1837
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1938

20-
- name: Checkout common scripts
21-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
- name: Download common repo
40+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
2241
with:
23-
repository: descope/common
24-
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
25-
path: .github/actions-common
42+
name: common-repo
43+
path: common-repo/
2644

2745
- name: Build
28-
uses: ./.github/actions-common/.github/actions/build
46+
uses: ./common-repo/.github/actions/build
2947
with:
3048
go_version: ${{ env.GO_VERSION }}
31-
scripts_folder: ./vendor/github.com/descope/common
49+
scripts_folder: ./common-repo/scripts
3250
APP_PEM: ${{ secrets.APP_PEM }}
3351
APP_ID: ${{ secrets.APP_ID }}
3452

3553
lint:
3654
name: Lint and more checks
3755
runs-on: ubuntu-latest
56+
needs: setup
3857
env:
3958
GITHUB_TOKEN: ${{ secrets.AUTHZCACHE_TO_COMMON }}
4059
steps:
4160
- name: Checkout code
4261
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4362

44-
- name: Checkout common scripts
45-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
63+
- name: Download common repo
64+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
4665
with:
47-
repository: descope/common
48-
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
49-
path: .github/actions-common
66+
name: common-repo
67+
path: common-repo/
5068

5169
- name: Lint and more checks
52-
uses: ./.github/actions-common/.github/actions/lint
70+
uses: ./common-repo/.github/actions/lint
5371
with:
5472
go_version: ${{ env.GO_VERSION }}
5573
scripts_folder: ./vendor/github.com/descope/common
@@ -59,21 +77,21 @@ jobs:
5977
test:
6078
name: Run Tests
6179
runs-on: ubuntu-latest
80+
needs: setup
6281
env:
6382
GITHUB_TOKEN: ${{ secrets.AUTHZCACHE_TO_COMMON }}
6483
steps:
6584
- name: Checkout code
6685
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6786

68-
- name: Checkout common scripts
69-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
87+
- name: Download common repo
88+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
7089
with:
71-
repository: descope/common
72-
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
73-
path: .github/actions-common
90+
name: common-repo
91+
path: common-repo/
7492

7593
- name: Run Tests
76-
uses: ./.github/actions-common/.github/actions/tests
94+
uses: ./common-repo/.github/actions/tests
7795
env:
7896
DATABASE_PASSWORD: ${{ env.DATABASE_PASSWORD }}
7997
with:
@@ -86,21 +104,21 @@ jobs:
86104
security:
87105
name: Run Security checks
88106
runs-on: ubuntu-latest
107+
needs: setup
89108
env:
90109
GITHUB_TOKEN: ${{ secrets.AUTHZCACHE_TO_COMMON }}
91110
steps:
92111
- name: Checkout code
93112
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
94113

95-
- name: Checkout common scripts
96-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
114+
- name: Download common repo
115+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
97116
with:
98-
repository: descope/common
99-
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
100-
path: .github/actions-common
117+
name: common-repo
118+
path: common-repo/
101119

102120
- name: Run Security checks
103-
uses: ./.github/actions-common/.github/actions/security
121+
uses: ./common-repo/.github/actions/security
104122
with:
105123
go_version: ${{ env.GO_VERSION }}
106124
scripts_folder: ./vendor/github.com/descope/common
@@ -110,7 +128,7 @@ jobs:
110128
pack:
111129
name: Pack and Upload
112130
runs-on: ubuntu-latest
113-
needs: build
131+
needs: [setup, build]
114132
permissions:
115133
packages: write
116134
contents: read
@@ -122,16 +140,14 @@ jobs:
122140
- name: Checkout code
123141
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
124142

125-
126-
- name: Checkout common scripts
127-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
143+
- name: Download common repo
144+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
128145
with:
129-
repository: descope/common
130-
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
131-
path: .github/actions-common
146+
name: common-repo
147+
path: common-repo/
132148

133149
- name: Pack and Upload
134-
uses: ./.github/actions-common/.github/actions/pack
150+
uses: ./common-repo/.github/actions/pack
135151
with:
136152
go_version: ${{ env.GO_VERSION }}
137153
action_token: ${{ secrets.AUTHZCACHE_TO_COMMON }}

0 commit comments

Comments
 (0)