-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (95 loc) · 3.33 KB
/
ci.yaml
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
107
108
109
110
111
112
on:
push:
branches:
- main
name: CI
jobs:
lint:
name: Lint
runs-on: [self-hosted, small]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
run: python -m pip install --upgrade poetry==1.5.1
- name: Config poetry
run: poetry config virtualenvs.create false
- name: Install dependencies
run: poetry install --only main,dev --no-interaction --no-ansi --no-cache
working-directory: ./slack_bot
- name: Lint
run: ruff .
working-directory: ./slack_bot
type_checking:
name: Static type checking
runs-on: [ self-hosted, small ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Poetry
run: python -m pip install --upgrade poetry==1.5.1
- name: Config poetry
run: poetry config virtualenvs.create false
- name: Install dependencies
run: poetry install --only main,dev --no-interaction --no-ansi --no-cache
working-directory: ./slack_bot
- name: Lint
run: mypy .
working-directory: ./slack_bot
deploy:
name: Deploy
needs:
- lint
- type_checking
concurrency:
group: production
runs-on: [self-hosted, small]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: hyperskill.azurecr.io/hyperskill
username: ${{ secrets.AZ_REGISTRY_USERNAME }}
password: ${{ secrets.AZ_REGISTRY_PASSWORD }}
- name: Build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: hyperskill.azurecr.io/hyperskill/dataslackbot:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha
- name: Set up Helm
uses: ./.github/workflows/actions/helm
with:
resource_group: ${{ vars.RESOURCE_GROUP }}
cluster_name: ${{ vars.CLUSTER_NAME }}
client_id: ${{ secrets.CLIENT_ID }}
client_secret: ${{ secrets.CLIENT_SECRET }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
- name: Deploy
run: |
echo "SLACK_APP_TOKEN=$(echo "${{ secrets.SLACK_APP_TOKEN }}" | base64)" >> $GITHUB_ENV
echo "SLACK_BOT_TOKEN=$(echo "${{ secrets.SLACK_BOT_TOKEN }}" | base64)" >> $GITHUB_ENV
echo "dockerConfigJson=$(echo "{\"auths\": {\"https://hyperskill.azurecr.io/hyperskill/\": {\"auth\": \"$(echo ${{ secrets.AZ_REGISTRY_USERNAME }}:${{ secrets.AZ_REGISTRY_PASSWORD}} | base64)\"}}}" | base64)" >> $GITHUB_ENV
helm upgrade data-slack-bot ./deploy/slack_bot \
--namespace data-slack-bot \
--install \
--wait \
--atomic \
--debug \
--set image.tag=${{ github.sha }} \
--set image.dockerConfigJson=${{ env.dockerConfigJson }} \
--set slack.appToken=${{ env.SLACK_APP_TOKEN }} \
--set slack.botToken=${{ env.SLACK_BOT_TOKEN }}