-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.33 KB
/
ci_nlp_dev.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
name: Colabot-nlp PY CI DEV
on:
pull_request:
branches: [dev]
jobs:
linting:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9.7]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install virtualenv
- run: make pylint
- run: make check-format
build-image:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io # registry
BRANCH: dev
IMAGE_NAME: ${{ github.repository }} # "ciscops/colabot-nlp"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Build and push image
uses: docker/build-push-action@v2
with:
network: host
context: ./
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{env.BRANCH}}
deploy:
needs: build-image
runs-on: self-hosted
steps:
- name: install jinja2
run: |
sudo apt-get install python3-pip -y
sudo pip3 install jinja2
- name: Checkout code
uses: actions/checkout@v2
- name: Get kubeConfig file from secrets
run: |
if [ ! -d ${HOME}/.kube ] ; then
mkdir ${HOME}/.kube
fi
echo "${{ secrets.KUBE_CONFIG }}" > ${HOME}/.kube/config
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.EKS_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.EKS_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Convert j2 template to yaml
run: python3 process-j2.py
env:
ENVIRONMENT: dev
NLP_SECRET: ${{ secrets.NLP_SECRET }}
- name: Apply and rollout
run: |
export PATH=/home/github/.local/bin/:$PATH
kubectl apply -f manifest/output-secrets-dev.yaml
kubectl apply -f manifest/output-manifest-dev.yaml
kubectl rollout restart deployment/colabot-nlp-dev
rm manifest/output-secrets-dev.yaml
rm manifest/output-manifest-dev.yaml