Skip to content

Commit

Permalink
feat: add inputs to k8s apply workflow (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
micheledellipaoli-pagopa authored Jan 7, 2025
1 parent 0c2045b commit 5e77ec1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/k8s-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tf-apply.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e77ec1

Please sign in to comment.