-
Notifications
You must be signed in to change notification settings - Fork 5
165 lines (147 loc) · 5.51 KB
/
release.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+-alpha"
jobs:
publish:
name: Build and Publish Container Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
REPO_PREFIX: ${{ format('azure/acr/dev/') }}
outputs:
git_tag: ${{ steps.get_git_tag.outputs.git_tag }}
steps:
- name: Get Git Tag
id: get_git_tag
run: echo ::set-output name=git_tag::${GITHUB_REF#refs/tags/}
- name: Check Out Source Code
if: ${{ success() }}
uses: actions/checkout@v2
with:
ref: ${{ steps.get_git_tag.outputs.git_tag }}
- name: Set Docker Image Tag
env:
GIT_TAG: ${{ steps.get_git_tag.outputs.git_tag }}
id: get_image_tag
run: echo ::set-output name=docker_tag::${GIT_TAG}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
if: ${{ success() }}
run: |
REGISTRY=${{ env.REGISTRY }} REPO_PREFIX=${{ env.REPO_PREFIX }} TAG=${{ steps.get_image_tag.outputs.docker_tag }} make build-image
- name: Push Image
if: ${{ success() }}
run: |
docker push ${{ env.REGISTRY }}/${{ env.REPO_PREFIX }}peerd:${{ steps.get_image_tag.outputs.docker_tag }}
ciCtr:
name: Run AKS CTR CI
runs-on: ubuntu-latest
needs: publish
permissions:
contents: read
id-token: write # This is required for requesting the JWT from AAD.
env:
TAG: ${{ needs.publish.outputs.git_tag }}
SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
steps:
- name: "Az CLI login"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# This is a temporary workaround. See: https://github.com/Azure/azure-cli/issues/28708#issuecomment-2049014471
- name: Fetch OID token every 4 mins
run: |
while true; do
token_request=$ACTIONS_ID_TOKEN_REQUEST_TOKEN
token_uri=$ACTIONS_ID_TOKEN_REQUEST_URL
token=$(curl -H "Authorization: bearer $token_request" "${token_uri}&audience=api://AzureADTokenExchange" | jq .value -r)
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -t ${{ secrets.AZURE_TENANT_ID }} --federated-token $token --output none
# Sleep for 4 minutes
sleep 240
done &
- name: Check Out Source Code
if: ${{ success() }}
uses: actions/checkout@v2
with:
ref: ${{ env.TAG }}
- name: "Make"
if: ${{ success() }}
run: |
PEERD_IMAGE_TAG=${{ env.TAG }} make tests-deps-install ci-aks-ctr
ciStreaming:
name: Run AKS Streaming CI
runs-on: ubuntu-latest
needs: [publish, ciCtr]
permissions:
contents: read
id-token: write # This is required for requesting the JWT from AAD.
env:
TAG: ${{ needs.publish.outputs.git_tag }}
SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
steps:
- name: "Az CLI login"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# This is a temporary workaround. See: https://github.com/Azure/azure-cli/issues/28708#issuecomment-2049014471
- name: Fetch OID token every 4 mins
run: |
while true; do
token_request=$ACTIONS_ID_TOKEN_REQUEST_TOKEN
token_uri=$ACTIONS_ID_TOKEN_REQUEST_URL
token=$(curl -H "Authorization: bearer $token_request" "${token_uri}&audience=api://AzureADTokenExchange" | jq .value -r)
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -t ${{ secrets.AZURE_TENANT_ID }} --federated-token $token --output none
# Sleep for 4 minutes
sleep 240
done &
- name: Check Out Source Code
if: ${{ success() }}
uses: actions/checkout@v2
with:
ref: ${{ env.TAG }}
- name: "Make"
if: ${{ success() }}
run: |
PEERD_IMAGE_TAG=${{ env.TAG }} make tests-deps-install ci-aks-streaming
tag:
name: Tag Release
runs-on: ubuntu-latest
needs: [publish, ciCtr, ciStreaming]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
REPO_PREFIX: ${{ format('azure/acr/dev/') }}
SOURCE_TAG: ${{ needs.publish.outputs.git_tag }}
TARGET_TAG: stable
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Tag ${{ env.SOURCE_TAG }}
if: ${{ success() }}
run: |
docker pull ${{ env.REGISTRY }}/${{ env.REPO_PREFIX }}peerd:${{ env.SOURCE_TAG }}
- name: Push Tag ${{ env.TARGET_TAG }}
if: ${{ success() }}
run: |
docker tag ${{ env.REGISTRY }}/${{ env.REPO_PREFIX }}peerd:${{ env.SOURCE_TAG }} ${{ env.REGISTRY }}/${{ env.REPO_PREFIX }}peerd:${{ env.TARGET_TAG }} && \
docker push ${{ env.REGISTRY }}/${{ env.REPO_PREFIX }}peerd:${{ env.TARGET_TAG }}