Skip to content

Commit e02fbf2

Browse files
committed
fix postgre auth
1 parent 5658004 commit e02fbf2

1 file changed

Lines changed: 32 additions & 28 deletions

File tree

.github/actions/deploy-env/action.yml

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,9 @@ inputs:
104104
runs:
105105
using: "composite"
106106
steps:
107-
# ── 1. Update GitOps repo ───────────────────────────────────────────────
108-
- name: "Checkout GitOps repo"
109-
uses: actions/checkout@v4
110-
with:
111-
repository: ${{ inputs.gitops-repo }}
112-
token: ${{ inputs.gitops-deploy-token }}
113-
path: _gitops
114-
115-
- name: "Patch image tag (${{ inputs.gitops-env }} → ${{ inputs.image-tag }})"
116-
shell: bash
117-
run: |
118-
docker run --rm --user root -v "$PWD/_gitops:/gitops" mikefarah/yq:4 \
119-
e '.backend.image.tag = "${{ inputs.image-tag }}" | .frontend.image.tag = "${{ inputs.image-tag }}"' \
120-
-i /gitops/environments/${{ inputs.target-environment }}/values.yaml
121-
122-
- name: "Commit & push GitOps change"
123-
shell: bash
124-
run: |
125-
cd _gitops
126-
git config user.name "github-actions[bot]"
127-
git config user.email "github-actions[bot]@users.noreply.github.com"
128-
git add environments/${{ inputs.target-environment }}/values.yaml
129-
git diff --cached --quiet && echo "No changes to commit" && exit 0
130-
git commit -m "chore(deploy): ${{ inputs.gitops-env }} image tag ${{ inputs.image-tag }} [skip ci]"
131-
git push origin main
132-
133-
# ── 2. Authenticate with AWS ────────────────────────────────────────────
107+
# ── 1. Authenticate with AWS & write K8s secret FIRST ──────────────────
108+
# Must happen before the gitops commit so that pods starting in response
109+
# to the ArgoCD sync always find a secret with the correct DATABASE_HOST.
134110
- name: "Authenticate with AWS"
135111
uses: ./.github/actions/aws-auth
136112
with:
@@ -144,7 +120,7 @@ runs:
144120
--name ${{ inputs.eks-cluster-name }} \
145121
--region ${{ inputs.aws-region }}
146122
147-
# ── 3. Upsert K8s DB secret ─────────────────────────────────────────────
123+
# ── 2. Upsert K8s DB secret ─────────────────────────────────────────────
148124
- name: "Upsert DB credentials secret"
149125
shell: bash
150126
run: |
@@ -157,6 +133,34 @@ runs:
157133
--from-literal=password=${{ inputs.db-password }} \
158134
--dry-run=client -o yaml | kubectl apply -f -
159135
136+
# ── 3. Update GitOps repo (triggers ArgoCD sync) ────────────────────────
137+
# K8s secret is already correct above — pods that start from this sync
138+
# will find DATABASE_HOST populated immediately.
139+
- name: "Checkout GitOps repo"
140+
uses: actions/checkout@v4
141+
with:
142+
repository: ${{ inputs.gitops-repo }}
143+
token: ${{ inputs.gitops-deploy-token }}
144+
path: _gitops
145+
146+
- name: "Patch image tag (${{ inputs.gitops-env }} → ${{ inputs.image-tag }})"
147+
shell: bash
148+
run: |
149+
docker run --rm --user root -v "$PWD/_gitops:/gitops" mikefarah/yq:4 \
150+
e '.backend.image.tag = "${{ inputs.image-tag }}" | .frontend.image.tag = "${{ inputs.image-tag }}"' \
151+
-i /gitops/environments/${{ inputs.target-environment }}/values.yaml
152+
153+
- name: "Commit & push GitOps change"
154+
shell: bash
155+
run: |
156+
cd _gitops
157+
git config user.name "github-actions[bot]"
158+
git config user.email "github-actions[bot]@users.noreply.github.com"
159+
git add environments/${{ inputs.target-environment }}/values.yaml
160+
git diff --cached --quiet && echo "No changes to commit" && exit 0
161+
git commit -m "chore(deploy): ${{ inputs.gitops-env }} image tag ${{ inputs.image-tag }} [skip ci]"
162+
git push origin main
163+
160164
# ── 4. Wait for ArgoCD Healthy + Synced ────────────────────────────────
161165
- name: "Wait for ArgoCD sync (${{ inputs.argocd-app-name }})"
162166
shell: bash

0 commit comments

Comments
 (0)