fix(ci): evaluate short SHA in bash step and include flux-system in root kustomization (#47)
### Summary of Changes - Evaluated `short_sha` inside a bash step (`id: vars`) so Docker `build-args` receives the expanded short SHA (e.g. `sha-4429a65`) rather than literal bash code strings. - Added `- flux-system` to `ci/k8s/clusters/production/kustomization.yaml` to prevent Flux from pruning its own `GitRepository` resource during reconciliation.
This commit is contained in:
1 parent
a31f75fb98
commit
7be6d23e94
4 files changed
+16
-5
No files matched your search
@@ -81,6 +81,10 @@ jobs:
|
|||||||
type=raw,value=latest
|
type=raw,value=latest
|
||||||
type=sha,format=short
|
type=sha,format=short
|
||||||
|
|
||||||
|
- name: Compute short SHA
|
||||||
|
id: vars
|
||||||
|
run: echo "short_sha=sha-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -90,8 +94,8 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
COMMIT_SHA=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
COMMIT_SHA=${{ steps.vars.outputs.short_sha }}
|
||||||
VERSION=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
VERSION=${{ steps.vars.outputs.short_sha }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy - Kubernetes (GitOps)
|
name: Deploy - Kubernetes (GitOps)
|
||||||
|
|||||||
@@ -357,6 +357,10 @@ jobs:
|
|||||||
type=raw,value=next
|
type=raw,value=next
|
||||||
type=sha,format=short
|
type=sha,format=short
|
||||||
|
|
||||||
|
- name: Compute short SHA
|
||||||
|
id: vars
|
||||||
|
run: echo "short_sha=sha-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -366,5 +370,5 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
COMMIT_SHA=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
COMMIT_SHA=${{ steps.vars.outputs.short_sha }}
|
||||||
VERSION=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
VERSION=${{ steps.vars.outputs.short_sha }}
|
||||||
@@ -265,9 +265,11 @@ jobs:
|
|||||||
# Extract MAJOR.MINOR for tagging
|
# Extract MAJOR.MINOR for tagging
|
||||||
MAJOR_MINOR=$(echo "${{ github.ref_name }}" | cut -d/ -f3 | sed 's/^v//')
|
MAJOR_MINOR=$(echo "${{ github.ref_name }}" | cut -d/ -f3 | sed 's/^v//')
|
||||||
MAJOR=$(echo "$MAJOR_MINOR" | cut -d. -f1)
|
MAJOR=$(echo "$MAJOR_MINOR" | cut -d. -f1)
|
||||||
|
SHORT_SHA="sha-$(echo ${{ github.sha }} | cut -c1-7)"
|
||||||
echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
|
echo "version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT
|
echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT
|
||||||
echo "major=$MAJOR" >> $GITHUB_OUTPUT
|
echo "major=$MAJOR" >> $GITHUB_OUTPUT
|
||||||
|
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Create and Push Tag
|
- name: Create and Push Tag
|
||||||
run: |
|
run: |
|
||||||
@@ -303,7 +305,7 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
build-args: |
|
build-args: |
|
||||||
COMMIT_SHA=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
COMMIT_SHA=${{ steps.version.outputs.short_sha }}
|
||||||
VERSION=v${{ steps.version.outputs.version }}
|
VERSION=v${{ steps.version.outputs.version }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
|||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
|
- flux-system
|
||||||
- ../../base/namespaces
|
- ../../base/namespaces
|
||||||
- ../../infrastructure/cert-manager
|
- ../../infrastructure/cert-manager
|
||||||
- ../../infrastructure/networking
|
- ../../infrastructure/networking
|
||||||
|
|||||||
Reference in new issue
Block a user