Skip to content

Commit 12eb77d

Browse files
committed
Add kubectl port-forward for self-hosted postgres in prod CD
1 parent 603c372 commit 12eb77d

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/cd_prod.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Continuous Deployment (Prod)
22
on:
33
push:
44
branches: [ production ]
5+
workflow_dispatch:
56
jobs:
67
build:
78
runs-on: ubuntu-latest
@@ -18,6 +19,21 @@ jobs:
1819

1920
- name: Set up Docker Buildx
2021
uses: docker/setup-buildx-action@v2
22+
23+
- name: Set up kubectl
24+
uses: azure/setup-kubectl@v1
25+
with:
26+
version: 'latest'
27+
28+
- name: Set KUBECONFIG environment variable
29+
run: mkdir $HOME/.kube && echo $KUBE_POSTGRES_CONFIG | base64 -d > $HOME/.kube/config
30+
env:
31+
KUBE_POSTGRES_CONFIG: ${{ secrets.KUBE_POSTGRES_CONFIG }}
32+
33+
- name: Proxy Database using Kubernetes
34+
run: |
35+
kubectl port-forward svc/postgres 5432:5432 -n 100xdevs &
36+
sleep 5
2137
2238
- name: Build and push
2339
uses: docker/build-push-action@v4
@@ -40,4 +56,4 @@ jobs:
4056
git config user.email "actions@github.com"
4157
git add prod/dailycode/deployment.yml
4258
git commit -m "Update dailycode image to ${{ github.sha }}"
43-
git push https://${PAT}@github.com/code100x/staging-ops.git main
59+
git push https://${PAT}@github.com/code100x/staging-ops.git main

0 commit comments

Comments
 (0)