-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (50 loc) · 1.72 KB
/
ci-cd.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
name: Docker Image CI
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: get version
id: get-version
run: |
echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- name: login to docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: create image
run: |
cd app
docker build -t kdash:${{ steps.get-version.outputs.VERSION }} .
- name: get image ID
id: image-id
run: |
echo ::set-output name=IMAGE_ID::$(docker images -q kdash:${{ steps.get-version.outputs.VERSION }})
- name: push image
run: |
docker tag ${{ steps.image-id.outputs.IMAGE_ID }} maheshkasbe/kdash:${{ steps.get-version.outputs.VERSION }}
docker push maheshkasbe/kdash:${{ steps.get-version.outputs.VERSION }}
- name: install yq
uses: mikefarah/yq@v4.15.1
- name: update yaml file
run: |
cd k8s
yq e -i '.spec.template.spec.containers[0].image="maheshkasbe/kdash:${{ steps.get-version.outputs.VERSION }}"' deployment.yaml
cat deployment.yaml
- name: Commit and push changes
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: k8s/deployment.yaml
destination_repo: Mahesh-Kasabe/K-Dash
destination_branch: master
destination_folder: k8s
user_email: maheshkasbe010@gmail.com
user_name: Mahesh-Kasabe
commit_message: update image version ${{ steps.get_version.outputs.VERSION }} in yml file