-
Notifications
You must be signed in to change notification settings - Fork 3
110 lines (99 loc) · 3.34 KB
/
build.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build Actions Runner
on:
push:
branches:
- main
paths:
- src/images/github-runner-linux/**
- src/images/github-runner-win/**
- src/infrastructure/acr/**
workflow_dispatch:
inputs:
buildLinuxRunner:
description: 'Build Linux Runner'
type: boolean
required: true
default: true
buildWindowsRunner:
description: 'Build Windows Runner'
type: boolean
required: true
default: true
env:
AZURE_LOCATION: australiaeast
ACR_ROOT: ${{ github.workspace }}/src/infrastructure/acr
LNX_RUNNER_ROOT: ${{ github.workspace }}/src/images/github-runner-linux
WIN_RUNNER_ROOT: ${{ github.workspace }}/src/images/github-runner-win
LNX_IMAGE_NAME: github-runners/github-runner-linux-amd64
WIN_IMAGE_NAME: github-runners/github-runner-win-amd64
IMAGE_VERSION: 1.0.0.${{ github.run_number }}
AZURE_RG: ${{ vars.ENV_AZURE_RG }}
ACR_NAME: ${{ vars.ENV_ACR_NAME }}
ACR_SERVER: ${{ vars.ENV_ACR_NAME }}.azurecr.io
jobs:
deployInfra:
name: Deploy Infra
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.ENV_AZURE_CREDENTIALS }}
- name: Create RG
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
if [[ $(az group exists --name $AZURE_RG) == true ]]; then
echo "Resource group already exists."
else
az group create --name $AZURE_RG --location $AZURE_LOCATION
fi
- name: Run PSRule
uses: ./.github/actions/ps-rule
with:
TEMPLATE_NAME: ACR
INPUT_PATH: ${{ env.ACR_ROOT }}/.test
- name: Deploy ACR
uses: ./.github/actions/deploy-acr
with:
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }}
ROOT: ${{ env.ACR_ROOT }}
AZURE_RG: ${{ env.AZURE_RG }}
ACR_NAME: ${{ env.ACR_NAME }}
publishLinux:
name: Publish Linux Image
runs-on: ubuntu-latest
needs: deployInfra
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || inputs.buildLinuxRunner }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Runner
uses: ./.github/actions/github-runner-build
with:
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }}
ACR_NAME: ${{ env.ACR_NAME }}
RUNNER_ROOT: ${{ env.LNX_RUNNER_ROOT }}
IMAGE_NAME: ${{ env.LNX_IMAGE_NAME }}
IMAGE_VERSION: ${{ env.IMAGE_VERSION }}
ACR_SERVER: ${{ env.ACR_SERVER }}
publishWindows:
name: Publish Windows Image
runs-on: windows-latest
needs: deployInfra
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' || inputs.buildWindowsRunner }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Runner
uses: ./.github/actions/github-runner-build
with:
AZURE_CREDENTIALS: ${{ secrets.ENV_AZURE_CREDENTIALS }}
ACR_NAME: ${{ env.ACR_NAME }}
RUNNER_ROOT: ${{ env.WIN_RUNNER_ROOT }}
IMAGE_NAME: ${{ env.WIN_IMAGE_NAME }}
IMAGE_VERSION: ${{ env.IMAGE_VERSION }}
ACR_SERVER: ${{ env.ACR_SERVER }}