Repository navigation
123 lines (110 loc) · 4.4 KB
/
Copy pathtest.yml
File metadata and controls
123 lines (110 loc) · 4.4 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Build and Deploy Python-sp
on:
push:
paths:
#- "./**"
workflow_dispatch:
env:
# ACR data
ACR_ADDR: testregistry9.azurecr.io
ACR_NAME: testregistry9
ACR_ADMIN_USER: testregistry9
DOCKER_CMD: "sudo docker"
IMAGE: python
# needed to access AKS
CLUSTER_NAME: k8-cluster2
CLUSTER_RG: k8-cluster_group2
NAMESPACE: default
# keyvault parameters
KEYVAULTNAME: testKVtomcat2
jobs:
build-and-package:
runs-on: ubuntu-latest
steps:
# standard GitHub Action
- name: Checkout
uses: actions/checkout@master
# with:
# ref: master
# Install pack CLI
- name: Install buildpack
run: |
(curl -sSL "https://github.com/buildpacks/pack/releases/download/v0.23.0/pack-v0.23.0-linux.tgz" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack)
# build image
- name: Run buildpack python
run: |
pack build ${{ env.ACR_NAME }}.azurecr.io/${{ env.IMAGE }}:${{ github.sha }} --buildpack 'gcr.io/paketo-buildpacks/python' --builder paketobuildpacks/builder:full --path ./src/
- name: login to acr using helm
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
HELM_EXPERIMENTAL_OCI: 1
run: |
SP_APPID=$(echo $AZURE_CREDENTIALS | jq -e -r 'select(.clientId != null) | .clientId')
SP_PASSWORD=$(echo $AZURE_CREDENTIALS | jq -e -r 'select(.clientSecret != null) | .clientSecret')
helm registry login $ACR_NAME.azurecr.io \
--username $SP_APPID \
--password $SP_PASSWORD
shell: bash
- name: Login to ACR
run: docker login -u ${{ env.ACR_ADMIN_USER }} -p ${{ secrets.ACR_PASSWORD }} ${{ env.ACR_ADDR }}
# push image to registry
- name: Tag and push python image
run: |
docker tag ${{ env.ACR_ADDR }}/${{ env.IMAGE }}:${{ github.sha }} ${{ env.ACR_ADDR }}/${{ env.IMAGE }}:latest
docker push ${{ env.ACR_ADDR }}/${{ env.IMAGE }}:${{ github.sha }}
docker push ${{ env.ACR_ADDR }}/${{ env.IMAGE }}:latest
deploy-python:
needs: build-and-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# point to the team's AKS cluster
- name: Set AKS cluster
uses: azure/aks-set-context@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ env.CLUSTER_RG }}
# Create the pull secret needed to access the repository
- name: Create pull secret
uses: Azure/k8s-create-secret@v1
with:
namespace: ${{ env.NAMESPACE }}
container-registry-url: ${{ env.ACR_ADDR }}
container-registry-username: ${{ env.ACR_NAME }}
container-registry-password: ${{ secrets.ACR_PASSWORD }}
secret-name: ${{ env.ACR_ADDR }}-pull-secret
# install helm
- uses: azure/setup-helm@v1
with:
version: 'latest' # default is latest stable
# Bake and deploy the application manifests
#
- name: Get User Assigned Managed Identity
id: getUserAssignedIdentity
run: |
echo "::set-output name=user_assigned_identity::`az aks show -g ${{ env.CLUSTER_RG }} -n ${{ env.CLUSTER_NAME }} --query identityProfile.kubeletidentity.clientId`"
echo "::add-mask::`az aks show -g ${{ env.CLUSTER_RG }} -n ${{ env.CLUSTER_NAME }} --query identityProfile.kubeletidentity.clientId`"
- name: bakeManifests
uses: azure/k8s-bake@v1
id: bakeManifests
with:
renderEngine: helm
helmChart: ./charts/ws
overrideFiles: ./charts/ws/values.yaml
overrides: |
config.keyVault.userAssignedIdentityID: 9f53d64a-7086-4c91-8b61-ac113801a816
config.keyVault.resourceGroup: ${{ env.CLUSTER_RG }}
config.keyVault.keyVaultName: ${{ env.KEYVAULTNAME }}
config.keyVault.tenantId: ${{ secrets.AZURE_TENANTID }}
helm-version: 'latest'
silent: 'false'
# deploy the kubernetes resources
- uses: Azure/[email protected]
with:
namespace: ${{ env.NAMESPACE }}
manifests: ${{ steps.bakeManifests.outputs.manifestsBundle }}
images: |
${{ env.ACR_ADDR }}/${{ env.IMAGE }}:${{ github.sha }}
imagepullsecrets: |
${{ env.ACR_ADDR }}-pull-secret