Skip to content

Commit

Permalink
fix deploy_with_gh_runner
Browse files Browse the repository at this point in the history
  • Loading branch information
aomegax committed May 2, 2024
1 parent ee2d4ed commit 5e78862
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ permissions:
contents: read

jobs:
setting_env:
name: Setting Environment
outputs:
env: ${{ steps.get_env.outputs.env }}
steps:
- id: get_env
run: |
if [[ ${{ inputs.environment}} == *"nexi"* ]]; then
if [[ ${{ inputs.environment}} == *"sit"* ]]; then
echo "env=dev" >> $GITHUB_OUTPUT
else
echo "env=uat" >> $GITHUB_OUTPUT
elif [[ ${{ inputs.environment}} == *"prf"* ]]; then
echo "env=uat" >> $GITHUB_OUTPUT
else
echo "env=${{ inputs.environment}}" >> $GITHUB_OUTPUT
fi
create_runner:
name: Create Runner
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
name: ${{ needs.setting_env.outputs.env }}
if: ${{ inputs.target == inputs.environment }}
outputs:
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
Expand All @@ -47,8 +65,9 @@ jobs:
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
if: ${{ inputs.target == inputs.environment }}
name: Deploy on AKS
environment: ${{ inputs.environment }}
environment: ${{ needs.setting_env.outputs.env }}
steps:

- name: Deploy DEV for PagoPA (Oracle or Postgres)
uses: pagopa/github-actions-template/aks-deploy@5db4c9108164a07d96527978da1c3febec934f22 #v1.11.1
if: ${{ inputs.environment == 'dev' }}
Expand All @@ -57,7 +76,7 @@ jobs:
client_id: ${{ secrets.CD_CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
env: ${{ needs.setting_env.outputs.env }}
namespace: ${{ vars.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
Expand All @@ -72,7 +91,7 @@ jobs:
client_id: ${{ secrets.CD_CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
env: ${{ needs.setting_env.outputs.env }}
namespace: ${{ vars.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
Expand All @@ -87,7 +106,7 @@ jobs:
client_id: ${{ secrets.CD_CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: "uat"
env: ${{ needs.setting_env.outputs.env }}
namespace: ${{ vars.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
Expand All @@ -102,7 +121,7 @@ jobs:
client_id: ${{ secrets.CD_CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
env: ${{ needs.setting_env.outputs.env }}
namespace: ${{ vars.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
Expand Down Expand Up @@ -132,7 +151,7 @@ jobs:
client_id: ${{ secrets.CD_CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
env: ${{ needs.setting_env.outputs.env }}
namespace: ${{ vars.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
Expand All @@ -144,7 +163,7 @@ jobs:
needs: [ create_runner, deploy ]
if: ${{ success() || failure() && inputs.target == inputs.environment }}
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
environment: ${{ needs.setting_env.outputs.env }}
steps:
- name: Cleanup GitHub Runner
id: cleanup_github_runner
Expand All @@ -163,7 +182,7 @@ jobs:
runs-on: ubuntu-latest
name: Update OpenAPI
if: ${{ inputs.target == inputs.environment }}
environment: ${{ inputs.environment }}
environment: ${{ needs.setting_env.outputs.env }}
steps:
- name: Checkout
id: checkout
Expand All @@ -189,5 +208,5 @@ jobs:
client_id: "${{ secrets.CD_CLIENT_ID }}"
tenant_id: "${{ secrets.TENANT_ID }}"
subscription_id: "${{ secrets.SUBSCRIPTION_ID }}"
tf_environment: "weu-${{ inputs.environment }}"
tf_environment: "weu-${{ needs.setting_env.outputs.env }}"
dir: "infra"

0 comments on commit 5e78862

Please sign in to comment.