-
Notifications
You must be signed in to change notification settings - Fork 9
68 lines (58 loc) · 1.84 KB
/
hello-world.yaml
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
name: hello-world
on:
push:
branches:
- "**"
paths:
- hello-world/**
- .github/workflows/hello-world.yaml
env:
IMAGE: mhraproductsnonprodregistry.azurecr.io/products/hello-world
jobs:
build-and-test:
name: Build, Test and Deploy
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v2
with:
path: products
- name: Docker login
uses: azure/docker-login@v1
with:
login-server: mhraproductsnonprodregistry.azurecr.io
username: mhraproductsnonprodregistry
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build, test and push Docker image
working-directory: ./products/hello-world
run: |
TAG="$(git rev-parse --short=7 ${{ github.sha }})"
make ci-master tag=$TAG
DIGEST="$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE}:${TAG})"
echo "TAG=$TAG" >>$GITHUB_ENV
echo "DIGEST=$DIGEST" >>$GITHUB_ENV
- name: Clone Deployments repo
uses: actions/checkout@v2
with:
repository: MHRA/deployments
path: deployments
token: ${{ secrets.DEPLOYMENTS_REPO_TOKEN }}
- name: Update image tag
uses: stefanprodan/kube-tools@v1
with:
kustomize: 3.4.0
command: |
set -eux
cd deployments/hello-world/overlays/dev
kustomize edit set image $DIGEST
git config --local user.email "[email protected]"
git config --local user.name "MHRA CI/CD"
git diff-index --quiet HEAD || git commit -am "CI: Update image for $TAG"
declare -i n
n=0
until [ $n -ge 5 ]
do
git push && break
n+=1
git pull --rebase
done