-
Notifications
You must be signed in to change notification settings - Fork 2
102 lines (85 loc) · 2.55 KB
/
weather-service.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
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
name: Weather Service
on:
push:
paths:
- .github/workflows/weather-service.yml
- weather-service/**
branches: ['master']
pull_request:
paths:
- .github/workflows/weather-service.yml
- weather-service/**
defaults:
run:
working-directory: ./weather-service
jobs:
build_deploy:
environment: prod
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: 'Install GitVersion'
uses: gittools/actions/gitversion/setup@v0.9.11
with:
versionSpec: '5.x'
- uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
state: all
- name: determine_version
uses: gittools/actions/gitversion/execute@v0.9.11
id: gitversion
with:
useConfigFile: true
configFilePath: 'GitVersion.yml'
# Docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Docker Tags
id: docker_tags
run: |
MAIN_TAG=msexp/weather-service:${{ steps.gitversion.outputs.SemVer }}
if [ "$REF" == "pull_request" ];
then
echo "::set-output name=tag::$MAIN_TAG"
else
echo "::set-output name=tag::$MAIN_TAG,msexp/weather-service:latest"
fi
echo "::set-output name=main_tag::$MAIN_TAG"
env:
REF: ${{ github.event_name }}
- name: Build and push image
uses: docker/build-push-action@v3
with:
context: ./weather-service
file: weather-service/Dockerfile
push: true
tags: ${{ steps.docker_tags.outputs.tag }}
# K8S
- name: Get K8S namespace
id: k8s_namespace
run: |
if [ "$REF" == "pull_request" ];
then
echo "::set-output name=namespace::rc-${{ steps.findPr.outputs.pr }}-gbauso"
else
echo "::set-output name=namespace::gbauso"
fi
env:
REF: ${{ github.event_name }}
- uses: actions-hub/kubectl@master
name: Update Discovery Master K8S
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: set image deployment/weather weather=${{ steps.docker_tags.outputs.main_tag }} -n=${{ steps.k8s_namespace.outputs.namespace }}