-
-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (87 loc) · 2.87 KB
/
master.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
103
104
105
106
name: Master CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-test:
name: Build & Test
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
concurrency: ci-${{ github.ref }}
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r tests/requirements.txt
- name: Test
run: pytest -v --cov=./ --cov-report xml
- name: Fix code coverage path
working-directory: ./
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: SonarCloud Scan
uses: sonarsource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
docker:
name: Publish Docker Image
needs: [ build-test ]
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/master'
outputs:
digest: ${{ steps.docker_build.outputs.digest }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: trackerforce/switcher-slack-app:latest
update-kustomize:
name: Deploy
needs: [ docker ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: 'master'
- name: Checkout Kustomize
uses: actions/checkout@v4
with:
token: ${{ secrets.ARGOCD_PAT }}
repository: switcherapi/switcher-deployment
ref: master
- name: Set up arkade-get
uses: alexellis/arkade-get@master
with:
kubectl: latest
kustomize: latest
- name: Update GitOps repository
run: |
cd switcher-slack-app/base
echo RELEASE_TIME=`date` > environment-properties.env
kustomize edit set image trackerforce/switcher-slack-app:latest=trackerforce/switcher-slack-app@${{ needs.docker.outputs.digest }}
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
git add .
git commit -m "[argocd] switcher-slack-app: ${{ needs.docker.outputs.digest }}"
git push