11# This is a basic workflow to help you get started with Actions
22
33name : Build
4+ permissions :
5+ contents : read
6+ packages : write
47
58# Controls when the action will run. Triggers the workflow on push or pull request
69# events but only for the master branch
6871 poetry run coverage run --branch -m pytest -s -v
6972 poetry run coverage xml
7073
74+ - uses : actions/setup-python@v6
75+ with :
76+ python-version : " 3.14"
77+ - name : Test coverage for CSIT OAS Validation API
78+ run : |
79+ export PATH=/root/.local/bin:$PATH
80+ sudo apt install -y nodejs npm
81+ sudo npm install -g @stoplight/spectral-cli@6.14.2
82+ cd microservices/csitOasValidationApi
83+ poetry env use python3.14
84+ poetry install --no-root
85+ ./checkout-ruleset-tags.sh ruleset_tag_cache || true
86+ export GITHUB_TAG_CACHE_PATH="$(realpath -m ./ruleset_tag_cache)"
87+ poetry run coverage run --branch -m pytest -s -v
88+ poetry run coverage xml
89+
7190 - name : SonarCloud Scan
7291 uses : sonarsource/sonarqube-scan-action@master
7392 env :
@@ -93,19 +112,31 @@ jobs:
93112 - name : Skip message
94113 if : steps.check.outputs.build_needed == 'false'
95114 run : echo "No changes in gatewayApi, skipping build"
96- - uses : docker/build-push-action@v1
115+ - name : Sanitize tag name
116+ if : steps.check.outputs.build_needed == 'true'
117+ id : tag
118+ run : echo "tag=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
119+ - name : Set up Docker Buildx
120+ if : steps.check.outputs.build_needed == 'true'
121+ uses : docker/setup-buildx-action@v3
122+ - name : Log in to GitHub Container Registry
97123 if : steps.check.outputs.build_needed == 'true'
124+ uses : docker/login-action@v3
98125 with :
99- registry : docker.pkg.github.com
100- username : $GITHUB_ACTOR
126+ registry : ghcr.io
127+ username : ${{ github.actor }}
101128 password : ${{ secrets.GITHUB_TOKEN }}
102- repository : bcgov/gwa-api/gwa-gateway-api
103- path : microservices/gatewayApi
104- dockerfile : microservices/gatewayApi/Dockerfile
105- tag_with_ref : true
106- tag_with_sha : false
107- add_git_labels : true
129+ logout : false
130+ - uses : docker/build-push-action@v5
131+ if : steps.check.outputs.build_needed == 'true'
132+ with :
133+ context : microservices/gatewayApi
134+ file : microservices/gatewayApi/Dockerfile
108135 push : true
136+ tags : ghcr.io/bcgov/gwa-api/gwa-gateway-api:${{ steps.tag.outputs.tag }}
137+ labels : |
138+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
139+ org.opencontainers.image.revision=${{ github.sha }}
109140
110141 gwa-scheduler :
111142 needs : sonar-scan
@@ -126,19 +157,31 @@ jobs:
126157 - name : Skip message
127158 if : steps.check.outputs.build_needed == 'false'
128159 run : echo "No changes in gatewayJobScheduler, skipping build"
129- - uses : docker/build-push-action@v1
160+ - name : Sanitize tag name
161+ if : steps.check.outputs.build_needed == 'true'
162+ id : tag
163+ run : echo "tag=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
164+ - name : Set up Docker Buildx
130165 if : steps.check.outputs.build_needed == 'true'
166+ uses : docker/setup-buildx-action@v3
167+ - name : Log in to GitHub Container Registry
168+ if : steps.check.outputs.build_needed == 'true'
169+ uses : docker/login-action@v3
131170 with :
132- registry : docker.pkg.github.com
133- username : $GITHUB_ACTOR
171+ registry : ghcr.io
172+ username : ${{ github.actor }}
134173 password : ${{ secrets.GITHUB_TOKEN }}
135- repository : bcgov/gwa-api/gwa-scheduler
136- path : microservices/gatewayJobScheduler
137- dockerfile : microservices/gatewayJobScheduler/Dockerfile
138- tag_with_ref : true
139- tag_with_sha : false
140- add_git_labels : true
174+ logout : false
175+ - uses : docker/build-push-action@v5
176+ if : steps.check.outputs.build_needed == 'true'
177+ with :
178+ context : microservices/gatewayJobScheduler
179+ file : microservices/gatewayJobScheduler/Dockerfile
141180 push : true
181+ tags : ghcr.io/bcgov/gwa-api/gwa-scheduler:${{ steps.tag.outputs.tag }}
182+ labels : |
183+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
184+ org.opencontainers.image.revision=${{ github.sha }}
142185
143186 gwa-kube-api :
144187 needs : sonar-scan
@@ -159,19 +202,31 @@ jobs:
159202 - name : Skip message
160203 if : steps.check.outputs.build_needed == 'false'
161204 run : echo "No changes in kubeApi, skipping build"
162- - uses : docker/build-push-action@v1
205+ - name : Sanitize tag name
163206 if : steps.check.outputs.build_needed == 'true'
207+ id : tag
208+ run : echo "tag=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
209+ - name : Set up Docker Buildx
210+ if : steps.check.outputs.build_needed == 'true'
211+ uses : docker/setup-buildx-action@v3
212+ - name : Log in to GitHub Container Registry
213+ if : steps.check.outputs.build_needed == 'true'
214+ uses : docker/login-action@v3
164215 with :
165- registry : docker.pkg.github.com
166- username : $GITHUB_ACTOR
216+ registry : ghcr.io
217+ username : ${{ github.actor }}
167218 password : ${{ secrets.GITHUB_TOKEN }}
168- repository : bcgov/gwa-api/gwa-kube-api
169- path : microservices/kubeApi
170- dockerfile : microservices/kubeApi/Dockerfile
171- tag_with_ref : true
172- tag_with_sha : false
173- add_git_labels : true
219+ logout : false
220+ - uses : docker/build-push-action@v5
221+ if : steps.check.outputs.build_needed == 'true'
222+ with :
223+ context : microservices/kubeApi
224+ file : microservices/kubeApi/Dockerfile
174225 push : true
226+ tags : ghcr.io/bcgov/gwa-api/gwa-kube-api:${{ steps.tag.outputs.tag }}
227+ labels : |
228+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
229+ org.opencontainers.image.revision=${{ github.sha }}
175230
176231 gwa-compatibility-api :
177232 needs : sonar-scan
@@ -192,16 +247,73 @@ jobs:
192247 - name : Skip message
193248 if : steps.check.outputs.build_needed == 'false'
194249 run : echo "No changes in compatibilityApi, skipping build"
195- - uses : docker/build-push-action@v1
250+ - name : Sanitize tag name
251+ if : steps.check.outputs.build_needed == 'true'
252+ id : tag
253+ run : echo "tag=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
254+ - name : Set up Docker Buildx
255+ if : steps.check.outputs.build_needed == 'true'
256+ uses : docker/setup-buildx-action@v3
257+ - name : Log in to GitHub Container Registry
196258 if : steps.check.outputs.build_needed == 'true'
259+ uses : docker/login-action@v3
197260 with :
198- registry : docker.pkg.github.com
199- username : $GITHUB_ACTOR
261+ registry : ghcr.io
262+ username : ${{ github.actor }}
200263 password : ${{ secrets.GITHUB_TOKEN }}
201- repository : bcgov/gwa-api/gwa-compatibility-api
202- path : microservices/compatibilityApi
203- dockerfile : microservices/compatibilityApi/Dockerfile
204- tag_with_ref : true
205- tag_with_sha : false
206- add_git_labels : true
264+ logout : false
265+ - uses : docker/build-push-action@v5
266+ if : steps.check.outputs.build_needed == 'true'
267+ with :
268+ context : microservices/compatibilityApi
269+ file : microservices/compatibilityApi/Dockerfile
270+ push : true
271+ tags : ghcr.io/bcgov/gwa-api/gwa-compatibility-api:${{ steps.tag.outputs.tag }}
272+ labels : |
273+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
274+ org.opencontainers.image.revision=${{ github.sha }}
275+
276+ gwa-csit-oas-validation-api :
277+ needs : sonar-scan
278+ name : Docker Image for gwa-csit-oas-validation-api
279+ runs-on : ubuntu-latest
280+ steps :
281+ - uses : actions/checkout@v4
282+ with :
283+ fetch-depth : 2
284+ - name : Check if build needed
285+ id : check
286+ run : |
287+ if git diff --name-only HEAD^ HEAD | grep -q "^microservices/csitOasValidationApi/\|^.github/workflows/dev.yml"; then
288+ echo "build_needed=true" >> $GITHUB_OUTPUT
289+ else
290+ echo "build_needed=false" >> $GITHUB_OUTPUT
291+ fi
292+ - name : Skip message
293+ if : steps.check.outputs.build_needed == 'false'
294+ run : echo "No changes in csitOasValidationApi, skipping build"
295+ - name : Sanitize tag name
296+ if : steps.check.outputs.build_needed == 'true'
297+ id : tag
298+ run : echo "tag=$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
299+ - name : Set up Docker Buildx
300+ if : steps.check.outputs.build_needed == 'true'
301+ uses : docker/setup-buildx-action@v3
302+ - name : Log in to GitHub Container Registry
303+ if : steps.check.outputs.build_needed == 'true'
304+ uses : docker/login-action@v3
305+ with :
306+ registry : ghcr.io
307+ username : ${{ github.actor }}
308+ password : ${{ secrets.GITHUB_TOKEN }}
309+ logout : false
310+ - uses : docker/build-push-action@v5
311+ if : steps.check.outputs.build_needed == 'true'
312+ with :
313+ context : microservices/csitOasValidationApi
314+ file : microservices/csitOasValidationApi/Dockerfile
207315 push : true
316+ tags : ghcr.io/bcgov/gwa-api/gwa-csit-oas-validation-api:${{ steps.tag.outputs.tag }}
317+ labels : |
318+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
319+ org.opencontainers.image.revision=${{ github.sha }}
0 commit comments