diff --git a/.github/workflows/k8s-apply.yaml b/.github/workflows/k8s-apply.yaml index 153674b..6ba7b07 100644 --- a/.github/workflows/k8s-apply.yaml +++ b/.github/workflows/k8s-apply.yaml @@ -12,6 +12,16 @@ on: required: true default: false type: boolean + run_k8s_workflow: + description: 'Run k8s deployment jobs' + required: true + default: false + type: boolean + run_tf_workflow: + description: 'Run TF apply job' + required: true + default: false + type: boolean permissions: id-token: write @@ -28,6 +38,8 @@ jobs: echo "- environment: \`${{ inputs.environment }}\`" >> $GITHUB_STEP_SUMMARY echo "- ref: \`${{ github.ref }}\`" >> $GITHUB_STEP_SUMMARY echo "- force_restart: \`${{ inputs.force_restart }}\`" >> $GITHUB_STEP_SUMMARY + echo "- run_k8s_workflow: \`${{ inputs.run_k8s_workflow }}\`" >> $GITHUB_STEP_SUMMARY + echo "- run_tf_workflow: \`${{ inputs.run_tf_workflow }}\`" >> $GITHUB_STEP_SUMMARY initChecks: runs-on: ubuntu-22.04 @@ -84,6 +96,7 @@ jobs: matrix: index: [1,2,3,4,5,6,7,8,9,10] fail-fast: false + if: ${{ inputs.run_k8s_workflow == true }} steps: - name: Start GitHub Runner id: start_runner @@ -105,6 +118,7 @@ jobs: deploy: needs: [ create_runner ] secrets: inherit + if: ${{ inputs.run_k8s_workflow == true }} uses: ./.github/workflows/k8s-apply-sub.yaml with: environment: ${{ inputs.environment }} @@ -113,7 +127,7 @@ jobs: delete_runner: name: Delete Self-Hosted Runner needs: [create_runner, deploy] - if: ${{ always() }} + if: ${{ always() && inputs.run_k8s_workflow == true }} runs-on: ubuntu-22.04 environment: ${{ inputs.environment }} strategy: @@ -133,6 +147,7 @@ jobs: tf_apply: secrets: inherit + if: ${{ inputs.run_tf_workflow == true }} uses: ./.github/workflows/tf-apply.yaml with: environment: ${{ inputs.environment }} diff --git a/.github/workflows/tf-apply.yaml b/.github/workflows/tf-apply.yaml index feeb2ce..a678dee 100644 --- a/.github/workflows/tf-apply.yaml +++ b/.github/workflows/tf-apply.yaml @@ -43,8 +43,8 @@ jobs: - id: set-outputs run: | - echo "microservices=$(find microservices -type f -path "*/$NORM_ENV/values.yaml" -exec dirname {} \; | awk -F'/' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT" - echo "cronjobs=$(find jobs -type f -path "*/$NORM_ENV/values.yaml" -exec dirname {} \; | awk -F'/' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT" + echo "microservices=$(find microservices -type f -path "*/$NORM_ENV/values.yaml" -exec yq '.name' {} \; | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT" + echo "cronjobs=$(find jobs -type f -path "*/$NORM_ENV/values.yaml" -exec yq '.name' {} \; | jq -R -s -c 'split("\n")[:-1]')" >> "$GITHUB_OUTPUT" terraform_apply_monitoring: name: Terraform Apply Monitoring