-
Notifications
You must be signed in to change notification settings - Fork 149
95 lines (81 loc) · 3.22 KB
/
cicd.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
name: Deploy ADL LRS Application (Python)
'on':
push:
branches:
- ci-testing
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7"]
#python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install ruff pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with ruff
# run: |
# # stop the build if there are Python syntax errors or undefined names
# ruff --format=github --select=E9,F63,F7,F82 --target-version=py37 .
# # default set of ruff rules with GitHub Annotations
# ruff --format=github --target-version=py37 .
# - name: Test with pytest
# run: |
# pytest
- name: Build and test
run: |
pip3 install -r requirements.txt
./test-lrs.sh
# deploy-dev:
# runs-on: ubuntu-latest
# environment: dev
# needs: build-and-test
# steps:
# - name: Configure SSH
# run: |
# mkdir -p ~/.ssh
# echo "${{ secrets.ADLNET_DEV_SSH_KEY }}" > ~/.ssh/id_rsa
# chmod 600 ~/.ssh/id_rsa
# ssh-keyscan "${{ secrets.ADLNET_DEV_HOST }} >> ~/.ssh/known_hosts
# - name: Deploy code on Dev
# run: |
# ssh ${{ secrets.ADLNET_DEV_HOST_USER }}@${{ secrets.ADLNET_DEV_HOST }} "cd ${{ secrets.ADLNET_DEV_PROJECT_DIR }} && git pull origin ${GITHUB_REF#refs/heads/} && sudo docker-compose up -d --build"
deploy-staging:
runs-on: ubuntu-latest
environment: staging
needs:
- build-and-test
#- deploy-dev
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.ADLNET_STAGING_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan "${{ secrets.ADLNET_STAGING_HOST }}" >> ~/.ssh/known_hosts
- name: Deploy code on Staging
run: |
ssh ${{ secrets.ADLNET_STAGING_HOST_USER }}@${{ secrets.ADLNET_STAGING_HOST }} "
cd ${{ secrets.ADLNET_STAGING_PROJECT_DIR }} && \
echo 'Pulling Latest Code from Repository...' && \
git pull origin ${GITHUB_REF#refs/heads/} && \
echo 'Copying Required Config files...' && \
sudo cp /home/ubuntu/workflow/settings.ini /home/ubuntu/ADL_LRS/settings.ini && \
#sudo cp /home/ubuntu/workflow/docker/settings.ini /home/ubuntu/ADL_LRS/docker/lrs/settings.ini && \
sudo cp /home/ubuntu/workflow/.env /home/ubuntu/ADL_LRS/.env && \
echo 'Copying installing ssl certificate...' && \
sudo ./init-ssl.sh localhost && \
echo 'Rebuilding Docker Containers..' && \
sudo docker-compose stop && \
sudo docker-compose build --no-cache && \
sudo docker-compose up -d && \
echo 'deployed successfully on server'"