forked from Azure/azure-provider-external-dns-e2e
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (88 loc) · 3.51 KB
/
e2ev2-provision-test.yaml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: E2E Version 2 Provision and Test
on:
workflow_call:
inputs:
ref:
type: string
skipRefCheck:
type: boolean
default: true
name:
type: string
required: true
permissions:
id-token: write
jobs:
provision:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-go@v5
with:
go-version: '~1.20.3'
cache-dependency-path: "**/*.sum"
- name: Azure login
uses: azure/login@v1.6.1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Run Azure CLI commands'
run: |
az account show
az group list
pwd
- name: Provision Infrastructure
shell: bash
run: (go run ./main.go infra --subscription="${{ secrets.AZURE_SUBSCRIPTION_ID }}" --tenant="${{ secrets.AZURE_TENANT_ID }}" --names="${{ inputs.name }}" --infra-file="./infrafolder/infra.json")
if: # avoids race condition security vulnerability by ensuring we are only running changes that were /ok-to-test'd
(github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) ||
inputs.skipRefCheck
- name: Ensure ref
uses: actions/github-script@v7
if: ${{ !((github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.sha != '' && contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) || inputs.skipRefCheck) }}
with:
script: core.setFailed('Ref is not latest')
- name: Upload infra file
uses: actions/upload-artifact@v3
with:
name: infra
path: infrafolder/infra.json
test:
needs: provision
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-go@v5
with:
go-version: '~1.20.3'
- name: Azure login
uses: azure/login@v1.6.1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: infra
path: infrafolder/
- name: Test
shell: bash
id: test
run: (go run ./main.go test --infra-file="infrafolder/infra.json")
if:
(github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) ||
inputs.skipRefCheck
- name: Ensure ref
uses: actions/github-script@v7
if: ${{ !((github.event_name == 'repository_dispatch' && github.event.client_payload.slash_command.args.named.sha != '' && contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha)) || inputs.skipRefCheck) }}
with:
script: core.setFailed('Ref is not latest')