-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 2 KB
/
cicd.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
name: KBOT-CICD
on:
push:
branches:
- main
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run test
run: make test
- name: Docker Hub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push Docker image
env:
APP: "kbot"
REGISTRY: ghcr.io/yuriikosiy
VERSION: $(git describe --tags --abbrev=0)-$(git rev-parse --short HEAD)
run: make image push
- name: Set VERSION
run: echo "VERSION=$(git describe --tags --abbrev=0)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build & Push Docker image to Docker Hub
env:
APP: "kbot"
VERSION: ${{ env.VERSION }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
run: |
docker build -t ${DOCKERHUB_USERNAME}/${APP}:${VERSION}-amd64 .
docker push ${DOCKERHUB_USERNAME}/${APP}:${VERSION}-amd64
cd:
name: CD
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: echo "VERSION=$(git describe --tags --abbrev=0)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- uses: mikefarah/yq@master
with:
cmd: yq -i '.image.tag=strenv(VERSION)' helm/values.yaml
- run: |
git config user.name github-actions
git config user.email [email protected]
git add helm/values.yaml
git commit -m "Updated Helm chart with new image tag $VERSION-linux-amd64"
git push