-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (98 loc) · 3.6 KB
/
check_n_push_image.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
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Check source code and push created image based on sources
on:
push:
branches:
- main
tags:
- 'v*'
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
workflow_dispatch:
jobs:
check-code:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Lint with ruff and pyright
run: |
make substitute-sources
pip install $(python3 setup.py --install-requirements)
pip install --requirement docs/notebooks/requirements.txt
pip install pre-commit==3.4.0
make pre-commit
docker-build-test-autotest:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Provide environment variable for autotests
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
echo "ACCESS_TOKEN=${ACCESS_TOKEN}" > .env
- name: Provides release environment variable if created new tag.
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
run: |
echo "IS_DEVELOPED=0" >> .env
- name: Get current util version
id: get_version
run: |
echo "::set-output name=version::$(grep --max-count 1 UTIL_VERSION Makefile | grep -Eo "[0-9]+[.][0-9]+[.][0-9]+")"
- name: Create main docker image, run tests and save image for the next job
run: |
export $(cat .env | xargs)
make docker-image DOCKER_TAG=${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:${{ steps.get_version.outputs.version }}
docker image save --output /tmp/codeplag-ubuntu20.04.tar ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:${{ steps.get_version.outputs.version }}
- name: Run autotests
run: |
make docker-autotest
- name: Save created deb package
uses: actions/upload-artifact@v3
with:
name: deb-package
path: debian/deb/
retention-days: 3
if-no-files-found: error
- name: Upload created image
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v3
with:
name: codeplag-ubuntu20.04
path: /tmp/codeplag-ubuntu20.04.tar
retention-days: 1
if-no-files-found: error
push-image:
runs-on: ubuntu-20.04
needs: [check-code, docker-build-test-autotest]
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download created in the previous stage image
uses: actions/download-artifact@v3
with:
name: codeplag-ubuntu20.04
path: /tmp
- name: Get current util version
id: get_version
run: |
echo "::set-output name=version::$(grep --max-count 1 UTIL_VERSION Makefile | grep -Eo "[0-9]+[.][0-9]+[.][0-9]+")"
- name: Load Docker created image
run: |
docker load --input /tmp/codeplag-ubuntu20.04.tar
docker image tag ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:${{ steps.get_version.outputs.version }} ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04:latest
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Push docker image
run: docker image push --all-tags ${{ secrets.DOCKER_HUB_USERNAME }}/codeplag-ubuntu20.04