-
Notifications
You must be signed in to change notification settings - Fork 0
Proj i04 7/clean up cicd pipeline #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
6ac1135
fix: per step authe using ARM_OIDC for terraform
giang-h-vu c7a1e0a
ci: fail on unknown cluster state and require explicit prod tag
giang-h-vu 4c5378a
ci: extract shared ansible-deploy composite action
giang-h-vu fc610ff
ci: consolidate PR checks into one path-filtered pipeline
giang-h-vu 141f6b3
fix: remove template injection attack in shell script by moving input…
giang-h-vu b6caf10
ci: gate image builds on CI and promote releases instead of rebuilding
giang-h-vu 415f338
chore: add lint, format and typecheck tool configs for all stacks
giang-h-vu 3b8afdf
chore: apply spotless to java services
giang-h-vu 7d01cee
chore: apply ruff format to python services
giang-h-vu f9b8a85
fix: satisfy stricter shared ruff ruleset in email service
giang-h-vu 471f1e6
fix: replace wildcard import and exempt test names from MethodName
giang-h-vu 12bbe4b
chore: apply prettier to web-client
giang-h-vu c75877e
chore: record reformat commits in .git-blame-ignore-revs
giang-h-vu 6258c9e
fix: resolve mypy findings in genai and email services
giang-h-vu ba9d456
chore: extend pre-commit with fast auto-fix hooks
giang-h-vu 5798714
ci: gate lint, format check and typecheck in the PR pipeline
giang-h-vu d3531f6
chore: apply pre-commit hygiene fixes repo-wide
giang-h-vu be4c38f
chore: exclude helm templates from check-yaml hook
giang-h-vu dca7d74
add preinstall in prepare for auto setup
giang-h-vu 3b37350
chore: improve codes security
giang-h-vu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Purely mechanical reformat commits — skip in git blame. | ||
| # Enable locally once: git config blame.ignoreRevsFile .git-blame-ignore-revs | ||
| # (GitHub's blame view picks this file up automatically.) | ||
|
|
||
| # chore: apply spotless to java services | ||
| 3b8afdf032ce10f07efefbcccd42ba6390a9baef | ||
| # chore: apply ruff format to python services | ||
| 7d01cee37613d6ac683ab3a161c55c3ae8b14eed | ||
| # chore: apply prettier to web-client | ||
| 12bbe4b6506cd69a78188018b1eaf09c79e3cd64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| name: Ansible deploy | ||
| description: >- | ||
| Installs the Ansible toolchain, runs the platform bootstrap and app deploy | ||
| playbooks against the target inventory, smoke-checks the public URL, and | ||
| writes a deploy summary. The caller must provide a kubeconfig via the | ||
| KUBECONFIG env var on the `uses:` step (the kubernetes.core modules read it | ||
| through the inventory's `kubeconfig` var). | ||
|
|
||
| inputs: | ||
| inventory: | ||
| description: "Inventory path relative to infra/ansible (e.g. inventories/dev/hosts.yml)" | ||
| required: true | ||
| image_tag: | ||
| description: "Final, ready-to-use image tag (callers normalize sha-/semver forms)" | ||
| required: true | ||
| vault_password: | ||
| description: "Ansible vault password for the target environment" | ||
| required: true | ||
| bootstrap: | ||
| description: "Set to 'true' to run bootstrap.yml (platform add-ons) before the deploy — dev/AKS only" | ||
| required: false | ||
| default: "false" | ||
| ingress_ip: | ||
| description: "Reserved static IP for ingress-nginx (required when bootstrap=true)" | ||
| required: false | ||
| default: "" | ||
| azure_lb_resource_group: | ||
| description: "Resource group holding the reserved IP (dev/AKS only)" | ||
| required: false | ||
| default: "" | ||
| app_url: | ||
| description: "Public URL to smoke-check after deploy (strict TLS; skipped when empty)" | ||
| required: false | ||
| default: "" | ||
| extra_args: | ||
| description: "Extra ansible-playbook args for deploy.yml (e.g. -e ingress_host=...)" | ||
| required: false | ||
| default: "" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| # Pinned so a deploy never breaks because pip resolved a different | ||
| # ansible-core that morning — bump deliberately, with a diff. | ||
| - name: Install Ansible + collections | ||
| shell: bash | ||
| run: | | ||
| pip install 'ansible-core==2.17.*' kubernetes | ||
| ansible-galaxy collection install -r infra/ansible/requirements.yml | ||
|
|
||
| - uses: azure/setup-helm@v4 | ||
| with: | ||
| version: v3.16.0 | ||
|
|
||
| # Only dev/AKS starts from a bare cluster; prod/TUM provides ingress-nginx | ||
| # + cert-manager, so there the step is skipped outright (grey in the step | ||
| # list). The caller opts in explicitly via the bootstrap input; the | ||
| # inventory's install_platform flag remains the inner guard in the playbook. | ||
| - name: Bootstrap platform (dev/AKS only) | ||
| if: inputs.bootstrap == 'true' | ||
| env: | ||
| vault_password: ${{ inputs.vault_password }} | ||
| inventory: ${{ inputs.inventory }} | ||
| ingress_ip: ${{ inputs.ingress_ip }} | ||
| azure_lb_resource_group: ${{ inputs.azure_lb_resource_group }} | ||
| shell: bash | ||
| working-directory: infra/ansible | ||
| run: | | ||
| trap 'rm -f vault-pass' EXIT | ||
| echo "$vault_password" > vault-pass | ||
| ansible-playbook -i "$inventory" playbooks/bootstrap.yml \ | ||
| --vault-password-file vault-pass \ | ||
| -e "ingress_ip=${ingress_ip}" \ | ||
| -e "azure_lb_resource_group=${azure_lb_resource_group}" | ||
|
|
||
| - name: Deploy app | ||
| shell: bash | ||
| env: | ||
| vault_password: ${{ inputs.vault_password }} | ||
| inventory: ${{ inputs.inventory }} | ||
| image_tag: ${{ inputs.image_tag }} | ||
| extra_args: ${{ inputs.extra_args }} | ||
| working-directory: infra/ansible | ||
| run: | | ||
| trap 'rm -f vault-pass' EXIT | ||
| echo "${vault_password}" > vault-pass | ||
| ansible-playbook -i "${inventory}" playbooks/deploy.yml \ | ||
| --vault-password-file vault-pass \ | ||
| -e "image_tag=${image_tag}" ${extra_args} | ||
|
|
||
| # Outside-in check: helm --wait (inside deploy.yml) already proved the pods | ||
| # are Ready; this proves the route to them — LB, ingress, TLS, DNS. No -k: | ||
| # an untrusted (staging-issuer) certificate must fail the deploy. | ||
| - name: Smoke check | ||
| if: inputs.app_url != '' | ||
| env: | ||
| app_url: ${{ inputs.app_url }} | ||
| shell: bash | ||
| run: | | ||
| echo "Probing ${app_url} ..." | ||
| for i in $(seq 1 12); do | ||
| if curl -sfo /dev/null --max-time 10 "${app_url}"; then | ||
| echo "OK (attempt $i)" | ||
| exit 0 | ||
| fi | ||
| sleep 10 | ||
| done | ||
| echo "::error::${app_url} did not answer within 2 minutes after deploy" | ||
| exit 1 | ||
|
|
||
| - name: Write deploy summary | ||
| shell: bash | ||
| env: | ||
| inventory: ${{ inputs.inventory }} | ||
| image_tag: ${{ inputs.image_tag }} | ||
| app_url: ${{ inputs.app_url }} | ||
| run: | | ||
| { | ||
| echo "## Deployed ✅" | ||
| echo "" | ||
| echo "| | |" | ||
| echo "|---|---|" | ||
| echo "| Inventory | \`${inventory}\` |" | ||
| echo "| Image tag | \`${image_tag}\` |" | ||
| if [ -n "${app_url}" ]; then | ||
| echo "| URL | ${app_url} |" | ||
| fi | ||
| echo "" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.