-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (64 loc) · 2.01 KB
/
Copy pathcd.yaml
File metadata and controls
81 lines (64 loc) · 2.01 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
name: CD
on:
push:
branches: ["master"]
paths: ["dev/**"]
jobs:
#-------------#
# Docker Push #
#-------------#
docker-push:
runs-on: ubuntu-latest
strategy:
matrix:
application: ["webapp", "api"]
steps:
- uses: actions/checkout@v3
name: Checkout source code
- uses: docker/setup-qemu-action@v2
name: Set up QEMU
- uses: docker/setup-buildx-action@v2
name: Set up Docker Buildx
- uses: docker/login-action@v2
name: Login to Docker Hub
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get tag
id: vars
run: echo "tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v4
name: Build
with:
context: dev/${{ matrix.application }}
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/gitops-example-${{ matrix.application }}:${{ steps.vars.outputs.tag }}
#----------------#
# Update DEV env #
#----------------#
update-dev-env:
runs-on: ubuntu-latest
needs: docker-push
steps:
- uses: actions/checkout@v3
name: Checkout source code
- name: Get tag
id: vars
run: echo "tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Update tag on values
working-directory: ops/environments/dev/05_applications
env:
APPS: "webapp api"
TAG: ${{ steps.vars.outputs.tag }}
run: |
for app in $APPS; do sed -i "s/tag: .*/tag: ${TAG}/" ${app}_values.yaml; done
- name: Commit and push changes
env:
APP: ${{ matrix.application }}
TAG: ${{ steps.vars.outputs.tag }}
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git add -A
git commit -m "Bump applications tag to ${TAG} on DEV environment"
git push