Add helm chart ci #18
Workflow file for this run
This file contains 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
name: Helm Chart CI | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: [ main ] | |
push: | |
branches: [ main ] | |
jobs: | |
helm-lint-and-template: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Helm | |
uses: azure/[email protected] | |
with: | |
version: 'latest' | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
check-latest: true | |
- name: Generate Helm Template and Write to File | |
run: | | |
helm template charts/service-chart > helm_output.txt | |
echo "::set-output name=helm_output_path::$(pwd)/helm_output.txt" | |
id: helm-operations | |
- name: Upload Helm template | |
uses: actions/upload-artifact@v4 | |
with: | |
name: helm-plans | |
path: '**/helm_output.txt' | |
- name: Create and Publish Summary Comments | |
run: | | |
HELM_OUTPUT_PATH="${{ steps.helm-operations.outputs.helm_output_path }}" | |
if [ -f "$HELM_OUTPUT_PATH" ]; then | |
SUMMARY=$(cat $HELM_OUTPUT_PATH) | |
echo "Helm Template Output for $DIR:" >> summary.md | |
echo '```' >> summary.md | |
cat $HELM_OUTPUT_PATH >> summary.md | |
echo '```' >> summary.md | |
fi | |
- name: Push Helm Output to PR | |
if: github.ref != 'refs/heads/main' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const summaryPath = './summary.md'; | |
const summary = fs.existsSync(summaryPath) ? fs.readFileSync(summaryPath, 'utf8') : 'No changes detected.'; | |
const body = `🔍 **Detailed Helm Plan Output:**\n${summary}\nPlease review the proposed changes. 👀`; | |
const comment = await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
body: body | |
}); | |
- name: Pre-commit Checks | |
uses: pre-commit/[email protected] |