-
Notifications
You must be signed in to change notification settings - Fork 2
80 lines (56 loc) · 2.25 KB
/
ci.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
name: Build, test & deploy
on: [ push, pull_request ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Docker login
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Disable make sync
run: touch submodule_sync
- name: Install pre-commit
run: pip install pre-commit==3.8.0
- name: Run pre-commit
run: pre-commit run -a
- name: Build image
run: make
- name: Run test
run: make test
- name: Build frontend
run: make build_frontend
- name: Copy frontend static files to backend
run: cp -r frontend/build/* backend/frontend_static/
- name: Build image to copy FE into it
run: make
- name: Tag sha
run: docker tag bis-backend ${{ env.IMAGE_NAME }}:$GITHUB_SHA
- name: Push sha
run: docker push ${{ env.IMAGE_NAME }}:$GITHUB_SHA
deploy-dev:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Deploy new tag
run: curl -X POST --fail -F token=${{ secrets.GITLAB_TOKEN }} -F "ref=main" -F "variables[TARGET_ENV]=devel" -F "variables[TARGET_TAG]=$GITHUB_SHA" https://gitlab.com/api/v4/projects/43999052/trigger/pipeline
deploy-prod:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Docker login
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Pull sha
run: docker pull ${{ env.IMAGE_NAME }}:$GITHUB_SHA
- name: Tag sha
run: docker tag ${{ env.IMAGE_NAME }}:$GITHUB_SHA ${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/*/}
- name: Push tag
run: docker push ${{ env.IMAGE_NAME }}:${GITHUB_REF#refs/*/}
- name: Deploy new tag
run: curl -X POST --fail -F token=${{ secrets.GITLAB_TOKEN }} -F "ref=main" -F "variables[TARGET_ENV]=production" -F "variables[TARGET_TAG]=${GITHUB_REF#refs/*/}" https://gitlab.com/api/v4/projects/43999052/trigger/pipeline