Skip to content

Commit b0c17f4

Browse files
author
github-copilot
committed
fix: avoid secrets check in job-level deploy condition for PRs
1 parent 8121f60 commit b0c17f4

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/ci-build-deploy.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,35 @@ jobs:
5151
deploy:
5252
needs: build-and-push
5353
runs-on: ubuntu-latest
54-
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') && secrets.KUBE_CONFIG != '' }}
54+
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') }}
5555
steps:
5656
- uses: actions/checkout@v4
57+
- name: Check KUBE_CONFIG secret
58+
run: |
59+
if [ -z "${{ secrets.KUBE_CONFIG }}" ]; then
60+
echo "KUBE_CONFIG secret is not configured; skipping deploy."
61+
exit 0
62+
fi
5763
- name: Install kubectl
64+
if: ${{ secrets.KUBE_CONFIG != '' }}
5865
uses: azure/setup-kubectl@v3
5966
with:
6067
version: 'latest'
6168
- name: Patch Job image to GHCR
69+
if: ${{ secrets.KUBE_CONFIG != '' }}
6270
run: |
6371
sed -i "s|image: bookkeeper-app:latest|image: ghcr.io/${{ github.repository_owner }}/bookkeeper-app:latest|" samples/book-app-project/k8s/job-list.yaml
6472
- name: Configure kubeconfig
73+
if: ${{ secrets.KUBE_CONFIG != '' }}
6574
run: echo "${{ secrets.KUBE_CONFIG }}" > kubeconfig
6675
- name: Apply k8s manifests
76+
if: ${{ secrets.KUBE_CONFIG != '' }}
6777
run: |
6878
kubectl --kubeconfig=kubeconfig apply -f samples/book-app-project/k8s/configmap-data.yaml
6979
kubectl --kubeconfig=kubeconfig apply -f samples/book-app-project/k8s/job-list.yaml
7080
- name: Wait for job completion
81+
if: ${{ secrets.KUBE_CONFIG != '' }}
7182
run: kubectl --kubeconfig=kubeconfig wait --for=condition=complete job/bookkeeper-list-job --timeout=120s || true
7283
- name: Fetch job logs
84+
if: ${{ secrets.KUBE_CONFIG != '' }}
7385
run: kubectl --kubeconfig=kubeconfig logs job/bookkeeper-list-job || true

0 commit comments

Comments
 (0)