Skip to content

bump replicas to 5 in prod #6

bump replicas to 5 in prod

bump replicas to 5 in prod #6

name: Render Manifests
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'guestbook/**'
permissions:
contents: write
jobs:
render:
name: Render ${{ matrix.env }} Manifests
runs-on: ubuntu-latest
strategy:
matrix:
include:
- env: dev
values-file: environments/dev-values.yaml
branch: env/dev
release-name: guestbook-dev
- env: staging
values-file: environments/staging-values.yaml
branch: env/staging
release-name: guestbook-staging
- env: prod
values-file: environments/prod-values.yaml
branch: env/prod
release-name: guestbook-prod
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: source
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Render Manifests
run: |
mkdir -p rendered/guestbook
helm template ${{ matrix.release-name }} source/guestbook \
-f source/guestbook/${{ matrix.values-file }} \
--output-dir rendered/guestbook
# helm template --output-dir creates a nested structure like:
# rendered/guestbook/guestbook/templates/deployment.yaml
# Flatten it to:
# rendered/guestbook/deployment.yaml
find rendered/guestbook -name '*.yaml' -mindepth 3 -exec mv {} rendered/guestbook/ \;
find rendered/guestbook -type d -empty -delete
- name: Checkout env branch
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
path: env-branch
fetch-depth: 0
continue-on-error: true
- name: Create orphan branch if it doesn't exist
if: failure()
run: |
mkdir -p env-branch
cd env-branch
git init
git checkout --orphan ${{ matrix.branch }}
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Update rendered manifests
run: |
rm -rf env-branch/guestbook
cp -r rendered/guestbook env-branch/guestbook
- name: Commit and push
run: |
cd env-branch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No changes to rendered manifests for ${{ matrix.env }}"
else
git commit -m "render: ${{ matrix.env }} manifests from ${{ github.sha }}"
git push origin HEAD:${{ matrix.branch }}
echo "Pushed rendered manifests to ${{ matrix.branch }}"
fi