update-kinetiq-backend-dev #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Kinetiq Backend Develop Image | |
| on: | |
| repository_dispatch: | |
| types: | |
| - update-kinetiq-backend-dev | |
| workflow_dispatch: | |
| inputs: | |
| image: | |
| description: Full image reference (e.g. ghcr.io/richixs/kinetiq-backend:dev-<sha>) | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: update-kinetiq-backend-develop-image | |
| cancel-in-progress: true | |
| jobs: | |
| update-image: | |
| if: github.event_name == 'workflow_dispatch' || github.event.client_payload.app == 'kinetiq-backend' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout GitOps repo | |
| uses: actions/checkout@v4 | |
| - name: Resolve image and tag | |
| id: vars | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| IMAGE_FROM_DISPATCH="${{ github.event.client_payload.image }}" | |
| IMAGE_FROM_INPUT="${{ inputs.image }}" | |
| IMAGE="${IMAGE_FROM_DISPATCH:-$IMAGE_FROM_INPUT}" | |
| if [[ -z "$IMAGE" ]]; then | |
| echo "No image provided from dispatch payload or workflow input." | |
| exit 1 | |
| fi | |
| if [[ "$IMAGE" != ghcr.io/*/kinetiq-backend:* ]]; then | |
| echo "Unexpected image format: $IMAGE" | |
| exit 1 | |
| fi | |
| TAG="${IMAGE##*:}" | |
| echo "image=$IMAGE" >> "$GITHUB_OUTPUT" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Update develop overlay image tag | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| FILE="apps/kinetiq-backend/overlays/develop/kustomization.yaml" | |
| TAG="${{ steps.vars.outputs.tag }}" | |
| sed -i.bak '/name: ghcr.io\/richixs\/kinetiq-backend/{n;s/newTag: .*/newTag: '"$TAG"'/;}' "$FILE" | |
| rm -f "$FILE.bak" | |
| echo "Updated $FILE to tag: $TAG" | |
| - name: Commit and push changes | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if git diff --quiet; then | |
| echo "No changes detected; skipping commit." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add apps/kinetiq-backend/overlays/develop/kustomization.yaml | |
| git commit -m "chore(kinetiq-backend): update develop image to ${{ steps.vars.outputs.tag }}" | |
| git push |