Skip to content

Commit 85c478a

Browse files
committed
Refactor CI workflow to use composite actions
Replaces inline shell scripts in CI jobs with reusable composite actions from .github/actions-common. Updates input parameters to use the 'with' syntax and adds a step to checkout common scripts for the pack job. This improves maintainability and consistency across workflow steps.
1 parent 35ab7cc commit 85c478a

File tree

1 file changed

+33
-69
lines changed

1 file changed

+33
-69
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,12 @@ jobs:
2525
path: .github/actions-common
2626

2727
- name: Build
28-
run: |
29-
cd .github/actions-common/.github/actions/build
30-
chmod +x action.sh 2>/dev/null || chmod +x *.sh 2>/dev/null || true
31-
if [ -f "action.sh" ]; then
32-
./action.sh
33-
elif [ -f "build.sh" ]; then
34-
./build.sh
35-
else
36-
echo "No build script found, checking action.yml"
37-
if [ -f "action.yml" ] || [ -f "action.yaml" ]; then
38-
echo "Found action definition but no script - this may be a composite action"
39-
fi
40-
fi
41-
env:
42-
INPUT_GO_VERSION: ${{ env.GO_VERSION }}
43-
INPUT_APP_PEM: ${{ secrets.APP_PEM }}
44-
INPUT_APP_ID: ${{ secrets.APP_ID }}
28+
uses: ./.github/actions-common/.github/actions/build
29+
with:
30+
go_version: ${{ env.GO_VERSION }}
31+
scripts_folder: ./vendor/github.com/descope/common
32+
APP_PEM: ${{ secrets.APP_PEM }}
33+
APP_ID: ${{ secrets.APP_ID }}
4534

4635
lint:
4736
name: Lint and more checks
@@ -60,23 +49,12 @@ jobs:
6049
path: .github/actions-common
6150

6251
- name: Lint and more checks
63-
run: |
64-
cd .github/actions-common/.github/actions/lint
65-
chmod +x action.sh 2>/dev/null || chmod +x *.sh 2>/dev/null || true
66-
if [ -f "action.sh" ]; then
67-
./action.sh
68-
elif [ -f "lint.sh" ]; then
69-
./lint.sh
70-
else
71-
echo "No lint script found, checking action.yml"
72-
if [ -f "action.yml" ] || [ -f "action.yaml" ]; then
73-
echo "Found action definition but no script - this may be a composite action"
74-
fi
75-
fi
76-
env:
77-
INPUT_GO_VERSION: ${{ env.GO_VERSION }}
78-
INPUT_APP_PEM: ${{ secrets.APP_PEM }}
79-
INPUT_APP_ID: ${{ secrets.APP_ID }}
52+
uses: ./.github/actions-common/.github/actions/lint
53+
with:
54+
go_version: ${{ env.GO_VERSION }}
55+
scripts_folder: ./vendor/github.com/descope/common
56+
APP_PEM: ${{ secrets.APP_PEM }}
57+
APP_ID: ${{ secrets.APP_ID }}
8058

8159
test:
8260
name: Run Tests
@@ -95,25 +73,15 @@ jobs:
9573
path: .github/actions-common
9674

9775
- name: Run Tests
98-
run: |
99-
cd .github/actions-common/.github/actions/tests
100-
chmod +x action.sh 2>/dev/null || chmod +x *.sh 2>/dev/null || true
101-
if [ -f "action.sh" ]; then
102-
./action.sh
103-
elif [ -f "tests.sh" ]; then
104-
./tests.sh
105-
else
106-
echo "No test script found, checking action.yml"
107-
if [ -f "action.yml" ] || [ -f "action.yaml" ]; then
108-
echo "Found action definition but no script - this may be a composite action"
109-
fi
110-
fi
76+
uses: ./.github/actions-common/.github/actions/tests
11177
env:
11278
DATABASE_PASSWORD: ${{ env.DATABASE_PASSWORD }}
113-
INPUT_GO_VERSION: ${{ env.GO_VERSION }}
114-
INPUT_APP_PEM: ${{ secrets.APP_PEM }}
115-
INPUT_APP_ID: ${{ secrets.APP_ID }}
116-
INPUT_MIN_COVERAGE: 100
79+
with:
80+
go_version: ${{ env.GO_VERSION }}
81+
scripts_folder: ./vendor/github.com/descope/common
82+
APP_PEM: ${{ secrets.APP_PEM }}
83+
APP_ID: ${{ secrets.APP_ID }}
84+
min_coverage: 100
11785

11886
security:
11987
name: Run Security checks
@@ -132,23 +100,12 @@ jobs:
132100
path: .github/actions-common
133101

134102
- name: Run Security checks
135-
run: |
136-
cd .github/actions-common/.github/actions/security
137-
chmod +x action.sh 2>/dev/null || chmod +x *.sh 2>/dev/null || true
138-
if [ -f "action.sh" ]; then
139-
./action.sh
140-
elif [ -f "security.sh" ]; then
141-
./security.sh
142-
else
143-
echo "No security script found, checking action.yml"
144-
if [ -f "action.yml" ] || [ -f "action.yaml" ]; then
145-
echo "Found action definition but no script - this may be a composite action"
146-
fi
147-
fi
148-
env:
149-
INPUT_GO_VERSION: ${{ env.GO_VERSION }}
150-
INPUT_APP_PEM: ${{ secrets.APP_PEM }}
151-
INPUT_APP_ID: ${{ secrets.APP_ID }}
103+
uses: ./.github/actions-common/.github/actions/security
104+
with:
105+
go_version: ${{ env.GO_VERSION }}
106+
scripts_folder: ./vendor/github.com/descope/common
107+
APP_PEM: ${{ secrets.APP_PEM }}
108+
APP_ID: ${{ secrets.APP_ID }}
152109

153110
pack:
154111
name: Pack and Upload
@@ -166,8 +123,15 @@ jobs:
166123
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
167124

168125

126+
- name: Checkout common scripts
127+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
128+
with:
129+
repository: descope/common
130+
token: ${{ secrets.AUTHZCACHE_TO_COMMON }}
131+
path: .github/actions-common
132+
169133
- name: Pack and Upload
170-
uses: descope/common/.github/actions/pack@main
134+
uses: ./.github/actions-common/.github/actions/pack
171135
with:
172136
go_version: ${{ env.GO_VERSION }}
173137
action_token: ${{ secrets.AUTHZCACHE_TO_COMMON }}

0 commit comments

Comments
 (0)