Skip to content

Commit c42f431

Browse files
vancodoctonCopilotgithub-advanced-security[bot]
authored
ci: add monorepo gate required status check (#390)
* chore: update CI workflow to enhance path detection and component checks * chore: merge ci/cd to gate.yml * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * chore: update paths-filter action to version 4.0.2 for improved functionality * chore: simplify output handling in gate workflow and remove frontend checks * chore: refine condition checks for backend and deploy outputs in gate workflow --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 28b012c commit c42f431

3 files changed

Lines changed: 107 additions & 77 deletions

File tree

.github/workflows/cd.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/gate.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
on:
2+
push:
3+
branches: ["main", "dev"]
4+
tags: ["v*.*.*"]
5+
pull_request:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
jobs:
10+
changes:
11+
name: detect changes
12+
permissions:
13+
contents: read
14+
runs-on: ubuntu-latest
15+
outputs:
16+
backend: ${{ steps.filter.outputs.backend == 'true' }}
17+
deploy: ${{ steps.filter.outputs.deploy == 'true' || steps.filter.outputs.backend == 'true' }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v7
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Detect changed paths
25+
id: filter
26+
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 #v4.0.2
27+
with:
28+
filters: |
29+
backend:
30+
- 'src/AppHost/**'
31+
- 'src/Core/**'
32+
- 'src/Infrastructure/**'
33+
- 'src/Infrastructure.PostgreSql/**'
34+
- 'src/Infrastructure.SqlServer/**'
35+
- 'src/Postgres.Migrator/**'
36+
- 'src/ServiceDefaults/**'
37+
- 'src/WebApi/**'
38+
- 'test/**'
39+
- 'MoneyGroup.slnx'
40+
- 'Directory.*.props'
41+
- 'Directory.*.targets'
42+
- 'global.json'
43+
- '.config/dotnet-tools.json'
44+
- 'testconfig.json'
45+
- '.github/workflows/**'
46+
deploy:
47+
- '.github/workflows/**'
48+
- '.dockerignore'
49+
50+
backend:
51+
uses: ./.github/workflows/dotnet.yml
52+
needs: changes
53+
if: ${{ needs.changes.outputs.backend }}
54+
secrets: inherit
55+
permissions:
56+
contents: read
57+
58+
deploy:
59+
uses: ./.github/workflows/docker.yml
60+
needs: changes
61+
if: ${{ needs.changes.outputs.deploy }}
62+
with:
63+
is-cd: ${{ github.event_name != 'pull_request' }}
64+
environment: Development
65+
secrets: inherit
66+
permissions:
67+
contents: read
68+
packages: write
69+
id-token: write
70+
71+
gate:
72+
name: gate
73+
needs: [changes, backend, deploy]
74+
if: ${{ always() }}
75+
runs-on: ubuntu-latest
76+
permissions: {}
77+
steps:
78+
- name: Enforce component checks by changed paths
79+
shell: bash
80+
run: |
81+
set -euo pipefail
82+
83+
changes_result='${{ needs.changes.result }}'
84+
if [[ "${changes_result}" != "success" ]]; then
85+
echo "Change detection job did not succeed."
86+
exit 1
87+
fi
88+
89+
be_needed='${{ needs.changes.outputs.backend }}'
90+
deploy_needed='${{ needs.changes.outputs.deploy }}'
91+
be_result='${{ needs.backend.result }}'
92+
deploy_result='${{ needs.deploy.result }}'
93+
94+
echo "backend needed: ${be_needed}, result: ${be_result}"
95+
echo "deploy needed: ${deploy_needed}, result: ${deploy_result}"
96+
97+
if [[ "${be_needed}" == "true" && "${be_result}" != "success" ]]; then
98+
echo "Backend checks were required but did not succeed."
99+
exit 1
100+
fi
101+
102+
if [[ "${deploy_needed}" == "true" && "${deploy_result}" != "success" ]]; then
103+
echo "Deploy checks were required but did not succeed."
104+
exit 1
105+
fi
106+
107+
echo "Monorepo gate passed."

0 commit comments

Comments
 (0)