forked from Azure/dev-box-images
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (58 loc) · 3.08 KB
/
build_images.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
name: Build Images
concurrency: ${{ github.ref }}
on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'images/**'
- 'scripts/**'
jobs:
# Build step to use container instances with Packer to create the custom images. Zero Trust Model
#buildContainers:
# runs-on: ubuntu-latest
# if: "!contains(join(github.event.commits.*.message), '+nobuild')"
# env:
# STORAGE_ACCOUNT: contosoimagesstorage
# SUBNET_ID: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Contoso-Images/providers/Microsoft.Network/virtualNetworks/contoso-images-vnet/subnets/builders
# steps:
# - uses: actions/checkout@v2
# - name: Login to Azure
# run: az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
# az cli installs bicep on demand the first time it's used
# using the --async argument in the command below simultaneously invokes several commands that use bicep
# so if bicep isn't already installed, the all initiate the install which throws a file busy error so we
# execute an arbitrary az bicep command here (and get the latest updates in the process)
# - name: Ensure Bicep
# run: az bicep upgrade
# - name: Deploy Build ACI Containers
# run: python "./builder/aci.py" --async --repository "${{ github.repositoryUrl }}" --revision "${{ github.sha }}" --token "${{ github.token }}" --client-id "${{ secrets.AZURE_CLIENT_ID }}" --client-secret "${{ secrets.AZURE_CLIENT_SECRET }}" --storage-account "${{ env.STORAGE_ACCOUNT }}" --subnet-id "${{ env.SUBNET_ID }}"
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Build step to use Azure Image builder or Packer natively to create the custom images.
prepare:
runs-on: ubuntu-latest
if: "!contains(join(github.event.commits.*.message), '+nobuild')"
outputs:
build: ${{ steps.images.outputs.build }}
images: ${{ steps.images.outputs.images }}
steps:
- uses: actions/checkout@v2
- name: Login to Azure
run: az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
- name: Get Image Definitions
id: images
run: python "./builder/image.py"
build:
needs: prepare
runs-on: ubuntu-latest
# this is needed to avoid workflow errors in case of an empty matrix
if: ${{ needs.prepare.outputs.build == 'true' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare.outputs.images) }}
steps:
- uses: actions/checkout@v2
- name: Login to Azure
run: az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
- name: Build ${{ matrix.name }} with ${{ matrix.builder }}
run: python "./builder/build.py" --suffix ${{ github.run_number }} --images ${{ matrix.name }}