-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (93 loc) · 3.26 KB
/
Copy pathrelease-image.yml
File metadata and controls
103 lines (93 loc) · 3.26 KB
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
name: Release to Community
on:
workflow_call:
inputs:
image_run_number:
description: 'Image run number'
required: true
type: string
release:
description: 'Release version'
type: string
required: true
image_name:
description: 'Image name'
type: string
required: true
os_type:
description: 'OS type'
type: string
required: true
default: 'Linux'
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout this Projects Wiki
uses: actions/checkout@v3
with:
repository: 'cloudyspells/ado-agent-ms-stack.wiki'
path: wiki
- name: Download readme artifact
uses: actions/download-artifact@v2
with:
name: Readme
path: readme
- name: Copy readme to wiki
run: cp -r readme/* wiki
- name: Commit and push changes to wiki
shell: bash
working-directory: ./wiki
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "generated docs from actions workflow"
git push
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create Managed Image from VHD
uses: azure/CLI@v1
with:
inlineScript: |
# Get the latest VHD URL from the storage account
IMAGE_URL=$(az storage blob list \
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \
--container-name system \
--query "[?contains(name, 'vhd')].name" \
--output tsv \
| sort -r \
| head -n 1 \
| xargs -I {} az storage blob url \
--account-name ${{ secrets.AZURE_STORAGE_ACCOUNT }} \
--container-name system \
--name {} \
--output tsv)
az image create \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--name ${{ inputs.image_name }}-${{ inputs.image_run_number }} \
--source $IMAGE_URL \
--os-type ${{ inputs.os_type }} \
--location westeurope \
--force-string
- name: Publish to Shared Image Gallery
uses: azure/CLI@v1
with:
inlineScript: |
# Get the managed image ID
IMAGE_ID=$(az image list --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --query "[?contains(name, '${{ inputs.image_name }}-${{ inputs.image_run_number }}')].id" -o tsv)
az sig image-version create \
--resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} \
--gallery-name ${{ secrets.AZURE_GALLERY_NAME }} \
--gallery-image-definition 'ado-agent-${{ inputs.image_name }}' \
--gallery-image-version ${{ inputs.release }} \
--managed-image $IMAGE_ID \
--os-state generalized \
--os-type ${{ inputs.os_type }} \
--exclude-from-cleaning ${{ secrets.AZURE_EXCLUDE_FROM_CLEANING }} \
--force-string