From 20215c45cb00df04b7ceefc33631cadf02474af2 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 09:20:01 +0200 Subject: [PATCH 1/7] feat: adjust deployment to work with migrated helm charts --- .github/workflows/deployment.yaml | 53 ++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index e21c769..c54e8b2 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -2,15 +2,31 @@ name: Reusable Deployment on: workflow_call: inputs: + appName: + required: false + type: string author: required: true description: The author of the change that triggers the deployment type: string + chartInAppRepo: + required: false + description: Specify if chart is migrated into the application's repository + default: false + type: boolean configurationFilepath: required: false description: The path to the application configuration file default: ./plconfig.yaml type: string + containerContext: + required: false + default: . + type: string + containerFile: + required: false + default: Containerfile + type: string description: required: true description: The description of the change (e.g. the commit title) @@ -19,6 +35,10 @@ on: required: true description: The application environment. Can be test, staging or prod. type: string + namespace: + required: false + description: EKS namespace + type: string ref: required: false description: The github ref to deploy @@ -37,6 +57,9 @@ on: required: false description: The url where the application is served type: string + versionKey: + required: false + type: string secrets: repoAccessToken: required: true @@ -44,6 +67,7 @@ on: jobs: read_schema_version: runs-on: ${{ inputs.runner }} + if: inputs.chartInAppRepo == false outputs: version: ${{ steps.version.outputs.result }} steps: @@ -57,7 +81,7 @@ jobs: detect_declarations: runs-on: ${{ inputs.runner }} needs: [read_schema_version] - if: needs.read_schema_version.outputs.version == 'v2' + if: needs.read_schema_version.outputs.version == 'v2' && inputs.chartInAppRepo == false outputs: has-kubernetes: ${{ steps.has-kubernetes.outputs.result }} steps: @@ -76,11 +100,13 @@ jobs: - name: Checkout current git repository uses: actions/checkout@v3 - name: Load plconfig values + if: inputs.chartInAppRepo == false id: values uses: mikefarah/yq@v4.30.8 with: cmd: yq "." ${{ inputs.configurationFilepath }} -o=json -I=0 - name: Load k8s deployment variables + if: inputs.chartInAppRepo == false id: k8s run: | # shellcheck disable=SC2129,SC2086 @@ -107,7 +133,32 @@ jobs: echo "url=$URL" >> $GITHUB_OUTPUT # shellcheck disable=SC2086 echo "status-url=$STATUS_URL" >> $GITHUB_OUTPUT + - name: Load k8s deployment variables + if: inputs.chartInAppRepo == true + id: k8s + run: | + # shellcheck disable=SC2129,SC2086 + echo "namespace=${{ inputs.namespace }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "version-key=${{ inputs.versionKey }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-context=${{ inputs.containerContext }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-file=${{ inputs.Containerfile }}" >> $GITHUB_OUTPUT + if [[ "${{ inputs.env }}" == 'prod' ]] + then + URL="https://${{ inputs.appName }}.parcellab.dev" + STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" + else + URL="https://${{ inputs.appName }}.${{ inputs.env }}.parcellab.dev" + STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" STATUS_URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.prod.metadata.statusUrl }}" + fi + # shellcheck disable=SC2086 + echo "url=$URL" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "status-url=$STATUS_URL" >> $GITHUB_OUTPUT - name: Create Github ${{ fromJSON(steps.values.outputs.result).name }} k8s deployment + if: inputs.chartInAppRepo == false uses: chrnorm/deployment-action@v2 with: auto-merge: false From fbf5cd703527f516d036fcb4854cf8cd38afb55a Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 09:20:59 +0200 Subject: [PATCH 2/7] remove url --- .github/workflows/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index c54e8b2..d3ca34a 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -151,7 +151,7 @@ jobs: STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" else URL="https://${{ inputs.appName }}.${{ inputs.env }}.parcellab.dev" - STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" STATUS_URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.prod.metadata.statusUrl }}" + STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" fi # shellcheck disable=SC2086 echo "url=$URL" >> $GITHUB_OUTPUT From d0aca12ece1339c72dbccc20f31258e0df7ef9fb Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 09:54:48 +0200 Subject: [PATCH 3/7] rework --- .github/workflows/deployment.yaml | 51 +++++++++++-------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index d3ca34a..7d702e9 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -109,42 +109,27 @@ jobs: if: inputs.chartInAppRepo == false id: k8s run: | - # shellcheck disable=SC2129,SC2086 - echo "namespace=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.namespace }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "version-key=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.versionKey }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "container-context=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.container.context || '.' }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "container-file=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.container.file || 'Containerfile' }}" >> $GITHUB_OUTPUT - if [[ "${{ inputs.env }}" == 'prod' ]] + if [[ ${{ "inputs.chartInAppRepo" }} == 'false' then - URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.prod.metadata.url }}" - STATUS_URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.prod.metadata.statusUrl }}" - elif [[ "${{ inputs.env }}" == 'staging' ]] - then - URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.staging.metadata.url }}" - STATUS_URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.staging.metadata.statusUrl }}" + # shellcheck disable=SC2129,SC2086 + echo "namespace=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.namespace }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "version-key=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.versionKey }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-context=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.container.context || '.' }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-file=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.container.file || 'Containerfile' }}" >> $GITHUB_OUTPUT else - URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.test.metadata.url }}" - STATUS_URL="${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.env.prod.metadata.statusUrl }}" + # shellcheck disable=SC2129,SC2086 + echo "namespace=${{ inputs.namespace }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "version-key=${{ inputs.versionKey }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-context=${{ inputs.containerContext }}" >> $GITHUB_OUTPUT + # shellcheck disable=SC2086 + echo "container-file=${{ inputs.Containerfile }}" >> $GITHUB_OUTPUT fi - # shellcheck disable=SC2086 - echo "url=$URL" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "status-url=$STATUS_URL" >> $GITHUB_OUTPUT - - name: Load k8s deployment variables - if: inputs.chartInAppRepo == true - id: k8s - run: | - # shellcheck disable=SC2129,SC2086 - echo "namespace=${{ inputs.namespace }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "version-key=${{ inputs.versionKey }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "container-context=${{ inputs.containerContext }}" >> $GITHUB_OUTPUT - # shellcheck disable=SC2086 - echo "container-file=${{ inputs.Containerfile }}" >> $GITHUB_OUTPUT + if [[ "${{ inputs.env }}" == 'prod' ]] then URL="https://${{ inputs.appName }}.parcellab.dev" From f49579d32beeeb697e37545a1c3414777004299b Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 09:56:04 +0200 Subject: [PATCH 4/7] run linter --- .github/workflows/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index 7d702e9..f6d2662 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -129,7 +129,7 @@ jobs: # shellcheck disable=SC2086 echo "container-file=${{ inputs.Containerfile }}" >> $GITHUB_OUTPUT fi - + if [[ "${{ inputs.env }}" == 'prod' ]] then URL="https://${{ inputs.appName }}.parcellab.dev" From 0fd7f3c9f64e6b5ab7d092e465c8328a8dc79981 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 09:59:33 +0200 Subject: [PATCH 5/7] close the bracket --- .github/workflows/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index f6d2662..f9321dd 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -109,7 +109,7 @@ jobs: if: inputs.chartInAppRepo == false id: k8s run: | - if [[ ${{ "inputs.chartInAppRepo" }} == 'false' + if [[ ${{ "inputs.chartInAppRepo" }} ]] == 'false' then # shellcheck disable=SC2129,SC2086 echo "namespace=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.namespace }}" >> $GITHUB_OUTPUT From f296cebc0f081e6f4bc557226b9f8031be008abc Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 10:04:09 +0200 Subject: [PATCH 6/7] fix conditional --- .github/workflows/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index f9321dd..aa4e542 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -109,7 +109,7 @@ jobs: if: inputs.chartInAppRepo == false id: k8s run: | - if [[ ${{ "inputs.chartInAppRepo" }} ]] == 'false' + if [[ ${{ "inputs.chartInAppRepo" }} == 'false' ]] then # shellcheck disable=SC2129,SC2086 echo "namespace=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.namespace }}" >> $GITHUB_OUTPUT From eaed62cd0b9d3802df11bc18ae2dd99b5433ab1c Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 10:06:14 +0200 Subject: [PATCH 7/7] move brackets --- .github/workflows/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index aa4e542..da32dc0 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -109,7 +109,7 @@ jobs: if: inputs.chartInAppRepo == false id: k8s run: | - if [[ ${{ "inputs.chartInAppRepo" }} == 'false' ]] + if [[ "${{ inputs.chartInAppRepo }}" == 'false' ]] then # shellcheck disable=SC2129,SC2086 echo "namespace=${{ fromJSON(steps.values.outputs.result).deployment.kubernetes.namespace }}" >> $GITHUB_OUTPUT