diff --git a/.github/workflows/app-backend.yml b/.github/workflows/app-backend.yml index afaecdc..7e3f473 100644 --- a/.github/workflows/app-backend.yml +++ b/.github/workflows/app-backend.yml @@ -3,14 +3,14 @@ name: Backend CI on: pull_request: branches: - - main + - develop paths: - "app/backend/**" - ".github/workflows/app-backend.yml" push: branches: - - main + - develop paths: - "app/backend/**" - ".github/workflows/app-backend.yml" @@ -113,7 +113,7 @@ jobs: name: Publish image runs-on: ubuntu-24.04 needs: security-scan - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: github.event_name == 'push' && github.ref == 'refs/heads/develop' env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository_owner }}/app-backend @@ -157,8 +157,8 @@ jobs: digest="$(oras resolve "$REGISTRY/$IMAGE_NAME:$GITHUB_SHA")" echo "digest=$digest" >> "$GITHUB_OUTPUT" - update-dev-chart: - name: Update dev configuration + update-image-reference: + name: Update image reference runs-on: ubuntu-24.04 needs: publish env: @@ -175,23 +175,23 @@ jobs: with: ref: ${{ github.sha }} - - name: Update dev image + - name: Update image reference run: | - sed -i "s|^ tag:.*| tag: \"$GITHUB_SHA\"|" kubernetes/helm/values-dev.yaml - sed -i "s|^ digest:.*| digest: \"$IMAGE_DIGEST\"|" kubernetes/helm/values-dev.yaml + sed -i "s|^ tag:.*| tag: \"$GITHUB_SHA\"|" kubernetes/helm/values.yaml + sed -i "s|^ digest:.*| digest: \"$IMAGE_DIGEST\"|" kubernetes/helm/values.yaml - - name: Create dev update pull request - id: dev_pr + - name: Create image update pull request + id: image_pr uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: - branch: automation/update-dev - base: main - add-paths: kubernetes/helm/values-dev.yaml - commit-message: "change: update dev image" - title: "change: update dev image" + branch: automation/update-image + base: develop + add-paths: kubernetes/helm/values.yaml + commit-message: "change: update application image" + title: "change: update application image" - name: Run Helm CI - if: steps.dev_pr.outputs.pull-request-operation == 'created' || steps.dev_pr.outputs.pull-request-operation == 'updated' + if: steps.image_pr.outputs.pull-request-operation == 'created' || steps.image_pr.outputs.pull-request-operation == 'updated' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh workflow run helm.yml --ref automation/update-dev \ No newline at end of file + run: gh workflow run helm.yml --ref automation/update-image diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 5b3e33c..c87758c 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -1,17 +1,9 @@ name: Helm CI on: - push: - branches: - - main - paths: - - "kubernetes/helm/**" - - "kubernetes/cluster/kind.yaml" - - ".github/workflows/helm.yml" - pull_request: branches: - - main + - develop paths: - "kubernetes/helm/**" - "kubernetes/cluster/kind.yaml" @@ -84,15 +76,15 @@ jobs: severity: HIGH,CRITICAL exit-code: "1" - merge-dev-update: + merge-image-update: needs: validate - if: github.event_name == 'workflow_dispatch' && github.ref_name == 'automation/update-dev' + if: github.event_name == 'workflow_dispatch' && github.ref_name == 'automation/update-image' runs-on: ubuntu-24.04 permissions: contents: write pull-requests: write steps: - - name: Merge dev update + - name: Merge image update env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr merge automation/update-dev --repo "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$GITHUB_SHA" + run: gh pr merge automation/update-image --repo "$GITHUB_REPOSITORY" --squash --delete-branch --match-head-commit "$GITHUB_SHA" diff --git a/argocd/application-sets/homelab-backend.yaml b/argocd/application-sets/homelab-backend.yaml index 96305f6..6fb8a21 100644 --- a/argocd/application-sets/homelab-backend.yaml +++ b/argocd/application-sets/homelab-backend.yaml @@ -14,16 +14,19 @@ spec: - environment: dev namespace: homelab-dev valuesFile: values-dev.yaml + targetRevision: develop autoSync: true - environment: stage namespace: homelab-stage valuesFile: values-stage.yaml + targetRevision: develop autoSync: false - environment: prod namespace: homelab-prod valuesFile: values-prod.yaml + targetRevision: main autoSync: false template: @@ -34,7 +37,7 @@ spec: source: repoURL: https://github.com/sotchenkov/devops-prac.git - targetRevision: main + targetRevision: '{{ .targetRevision }}' path: kubernetes/helm helm: releaseName: homelab-backend diff --git a/kubernetes/helm/values-dev.yaml b/kubernetes/helm/values-dev.yaml index 940e062..b7aa72c 100644 --- a/kubernetes/helm/values-dev.yaml +++ b/kubernetes/helm/values-dev.yaml @@ -1,11 +1,5 @@ replicaCount: 3 -image: - repository: ghcr.io/sotchenkov/app-backend - tag: "5c06d8ee250535169804a8839aebeaf502bfb817" - digest: "sha256:18727c716f9dc38ec60810c6afabc4acd8c5df23f5c0f6916dc8f95e73f7759a" - pullPolicy: IfNotPresent - config: environment: dev logLevel: info diff --git a/kubernetes/helm/values-prod.yaml b/kubernetes/helm/values-prod.yaml index 4a90b49..23e077a 100644 --- a/kubernetes/helm/values-prod.yaml +++ b/kubernetes/helm/values-prod.yaml @@ -1,11 +1,5 @@ replicaCount: 3 -image: - repository: ghcr.io/sotchenkov/app-backend - tag: 5edb397fa066a0695b61e635b8d7be930112efd5 - digest: sha256:bb12fc4a58ed37a6ebd4d51317c8c5bb5798fa413ab2270d0553d68ff414f406 - pullPolicy: IfNotPresent - config: environment: prod logLevel: warn diff --git a/kubernetes/helm/values-stage.yaml b/kubernetes/helm/values-stage.yaml index 1ed6e5c..8c51dab 100644 --- a/kubernetes/helm/values-stage.yaml +++ b/kubernetes/helm/values-stage.yaml @@ -1,11 +1,5 @@ replicaCount: 2 -image: - repository: ghcr.io/sotchenkov/app-backend - tag: 5edb397fa066a0695b61e635b8d7be930112efd5 - digest: sha256:bb12fc4a58ed37a6ebd4d51317c8c5bb5798fa413ab2270d0553d68ff414f406 - pullPolicy: IfNotPresent - config: environment: stage logLevel: warn diff --git a/kubernetes/helm/values.yaml b/kubernetes/helm/values.yaml index 45e58cd..46f0d90 100644 --- a/kubernetes/helm/values.yaml +++ b/kubernetes/helm/values.yaml @@ -1,10 +1,10 @@ replicaCount: 2 image: - repository: app-backend - tag: v1.1 - digest: "" - pullPolicy: Never + repository: ghcr.io/sotchenkov/app-backend + tag: "5c06d8ee250535169804a8839aebeaf502bfb817" + digest: "sha256:18727c716f9dc38ec60810c6afabc4acd8c5df23f5c0f6916dc8f95e73f7759a" + pullPolicy: IfNotPresent config: environment: local