From 7f6f91db91e332569a2c93f4c7b6d96632806860 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:20:53 +0200 Subject: [PATCH 1/7] chore: rework deployment to avoid skipping whole pipeline --- .github/workflows/deployment.yaml | 84 +++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index da32dc0..e5ef884 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -81,7 +81,7 @@ jobs: detect_declarations: runs-on: ${{ inputs.runner }} needs: [read_schema_version] - if: needs.read_schema_version.outputs.version == 'v2' && inputs.chartInAppRepo == false + if: needs.read_schema_version.outputs.version == 'v2' outputs: has-kubernetes: ${{ steps.has-kubernetes.outputs.result }} steps: @@ -100,36 +100,78 @@ 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: | - if [[ "${{ inputs.chartInAppRepo }}" == 'false' ]] + # 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' ]] then - # 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 + URL="https://${{ inputs.appName }}.parcellab.dev" + STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" else - # 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 + URL="https://${{ inputs.appName }}.${{ inputs.env }}.parcellab.dev" + STATUS_URL="https://argocd.${{ inputs.env }}.parcellab.dev/applications/${{ inputs.appName }}" 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 + uses: chrnorm/deployment-action@v2 + with: + auto-merge: false + environment: ${{ inputs.env }} + ref: ${{ inputs.ref }} + required-contexts: "" + payload: | + { + "author": ${{ toJSON(inputs.author) }}, + "description": ${{ toJSON(inputs.description) }}, + "env": ${{ toJSON(inputs.env) }}, + "name": ${{ toJSON(fromJSON(steps.values.outputs.result).name) }}, + "container": { + "context": ${{ toJSON(steps.k8s.outputs.container-context) }}, + "file": ${{ toJSON(steps.k8s.outputs.container-file) }} + }, + "kubernetes": { + "namespace": ${{ toJSON(steps.k8s.outputs.namespace) }}, + "versionKey": ${{ toJSON(steps.k8s.outputs.version-key) }} + }, + "schemaVersion": "v2", + "statusUrl": ${{ toJSON(steps.k8s.outputs.status-url) }}, + "url": ${{ toJSON(steps.k8s.outputs.url) }} + } + production-environment: "${{ inputs.env == 'prod' }}" + transient-environment: "${{ inputs.env == 'test' }}" + token: ${{ secrets.repoAccessToken }} + kubernetes-migrated-chart: + runs-on: ${{ inputs.runner }} + if: needs.detect_declarations.outputs.has-kubernetes == 'true' && inputs.chartInAppRepo == false + steps: + - name: Checkout current git repository + uses: actions/checkout@v3 + - name: Load k8s deployment variables + 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 47a20239c5014d0b8ddba406ce5d504f9170489c Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:22:31 +0200 Subject: [PATCH 2/7] fix --- .github/workflows/deployment.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index e5ef884..a99debc 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -157,7 +157,7 @@ jobs: token: ${{ secrets.repoAccessToken }} kubernetes-migrated-chart: runs-on: ${{ inputs.runner }} - if: needs.detect_declarations.outputs.has-kubernetes == 'true' && inputs.chartInAppRepo == false + if: needs.detect_declarations.outputs.has-kubernetes == 'true' && inputs.chartInAppRepo == true steps: - name: Checkout current git repository uses: actions/checkout@v3 @@ -185,7 +185,6 @@ jobs: # 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 c8c3a6e3f7014084d920531c4da1969da1ad4f3d Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:24:49 +0200 Subject: [PATCH 3/7] remove needs --- .github/workflows/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index a99debc..a5b63fb 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -157,7 +157,7 @@ jobs: token: ${{ secrets.repoAccessToken }} kubernetes-migrated-chart: runs-on: ${{ inputs.runner }} - if: needs.detect_declarations.outputs.has-kubernetes == 'true' && inputs.chartInAppRepo == true + if: inputs.chartInAppRepo == true steps: - name: Checkout current git repository uses: actions/checkout@v3 @@ -184,7 +184,7 @@ jobs: 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 + - name: Create Github deployment uses: chrnorm/deployment-action@v2 with: auto-merge: false From 0ddc5d6570edf3409876b0b3d15cf13798b24a6a Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:31:49 +0200 Subject: [PATCH 4/7] remove excess stuff --- .github/workflows/deployment.yaml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index a5b63fb..85694da 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -164,14 +164,6 @@ jobs: - name: Load k8s deployment variables 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" @@ -196,14 +188,14 @@ jobs: "author": ${{ toJSON(inputs.author) }}, "description": ${{ toJSON(inputs.description) }}, "env": ${{ toJSON(inputs.env) }}, - "name": ${{ toJSON(fromJSON(steps.values.outputs.result).name) }}, + "name": ${{ inputs.appName) }}, "container": { - "context": ${{ toJSON(steps.k8s.outputs.container-context) }}, - "file": ${{ toJSON(steps.k8s.outputs.container-file) }} + "context": ${{ inputs.containerContext }}, + "file": ${{ Containerfile }} }, "kubernetes": { - "namespace": ${{ toJSON(steps.k8s.outputs.namespace) }}, - "versionKey": ${{ toJSON(steps.k8s.outputs.version-key) }} + "namespace": ${{ inputs.namespace }}, + "versionKey": ${{ inputs.versionKey }} }, "schemaVersion": "v2", "statusUrl": ${{ toJSON(steps.k8s.outputs.status-url) }}, From 6490730aee4233a34924fcf92fd15a53716205f6 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:33:22 +0200 Subject: [PATCH 5/7] remove 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 85694da..1d5b5a0 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -188,7 +188,7 @@ jobs: "author": ${{ toJSON(inputs.author) }}, "description": ${{ toJSON(inputs.description) }}, "env": ${{ toJSON(inputs.env) }}, - "name": ${{ inputs.appName) }}, + "name": ${{ inputs.appName }}, "container": { "context": ${{ inputs.containerContext }}, "file": ${{ Containerfile }} From 8399ba2c62591a3c15668305f0682bdaed3da718 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 12:37:20 +0200 Subject: [PATCH 6/7] specify var type --- .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 1d5b5a0..b4d6af6 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -191,7 +191,7 @@ jobs: "name": ${{ inputs.appName }}, "container": { "context": ${{ inputs.containerContext }}, - "file": ${{ Containerfile }} + "file": ${{ inputs.Containerfile }} }, "kubernetes": { "namespace": ${{ inputs.namespace }}, From 557487eeb7dfb2578f6a76e260205ecdb8e1a165 Mon Sep 17 00:00:00 2001 From: Kirill Plis Date: Wed, 30 Apr 2025 15:28:04 +0200 Subject: [PATCH 7/7] add quotes --- .github/workflows/deployment.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deployment.yaml b/.github/workflows/deployment.yaml index b4d6af6..a476d39 100644 --- a/.github/workflows/deployment.yaml +++ b/.github/workflows/deployment.yaml @@ -188,14 +188,14 @@ jobs: "author": ${{ toJSON(inputs.author) }}, "description": ${{ toJSON(inputs.description) }}, "env": ${{ toJSON(inputs.env) }}, - "name": ${{ inputs.appName }}, + "name": "${{ inputs.appName }}", "container": { - "context": ${{ inputs.containerContext }}, - "file": ${{ inputs.Containerfile }} + "context": "${{ inputs.containerContext }}", + "file": "${{ inputs.Containerfile }}" }, "kubernetes": { - "namespace": ${{ inputs.namespace }}, - "versionKey": ${{ inputs.versionKey }} + "namespace": "${{ inputs.namespace }}", + "versionKey": "${{ inputs.versionKey }}" }, "schemaVersion": "v2", "statusUrl": ${{ toJSON(steps.k8s.outputs.status-url) }},