-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (73 loc) · 2.94 KB
/
deploy_with_github_runner.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Deploy on AKS
on:
workflow_call:
inputs:
environment:
required: true
description: The name of the environment where to deploy
type: string
env:
NAMESPACE: printit
APP_NAME: print-payment-notice-functions
permissions:
id-token: write
contents: read
jobs:
create_runner:
name: Create Runner
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
outputs:
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
steps:
- name: Create GitHub Runner
id: create_github_runner
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-create-action
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-create-action@main
with:
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
self_hosted_runner_image_tag: "latest"
deploy:
needs: [ create_runner ]
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
name: Deploy on AKS
environment: ${{ inputs.environment }}
steps:
- name: Deploy
uses: pagopa/github-actions-template/aks-deploy@main
with:
branch: ${{ github.ref_name }}
client_id: ${{ secrets.CLIENT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
env: ${{ inputs.environment }}
namespace: ${{ env.NAMESPACE }}
cluster_name: ${{ vars.CLUSTER_NAME }}
resource_group: ${{ vars.CLUSTER_RESOURCE_GROUP }}
app_name: ${{ env.APP_NAME }}
helm_upgrade_options: "--debug"
timeout: "8m0s"
cleanup_runner:
name: Cleanup Runner
needs: [ create_runner, deploy ]
if: ${{ success() || failure() }}
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
steps:
- name: Cleanup GitHub Runner
id: cleanup_github_runner
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-cleanup-action
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-cleanup-action@0ee2f58fd46d10ac7f00bce4304b98db3dbdbe9a
with:
client_id: ${{ secrets.CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }}
runner_name: ${{ needs.create_runner.outputs.runner_name }}
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}