-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (79 loc) · 2.87 KB
/
build-and-deploy.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
name: Aang's stocks
# Run this workflow every time a new commit pushed to your repository
on: push
jobs:
test:
# Name the Job
name: Test and lint application
# Set the type of machine to run on
runs-on: ubuntu-latest
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2
# TODO: install poetry and test code
- name: Install poetry dependencies
run: |-
cd web-app
pip3 install poetry
poetry install
- name: Lint
run: |-
cd web-app
poetry run flake8
- name: Run tests
run: |-
cd web-app
poetry run pytest
build:
# Name the Job
name: Build and publish docker image
# Set the type of machine to run on
runs-on: ubuntu-latest
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v2
# TODO: build and publish docker images
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push web-app
uses: docker/build-push-action@v2
with:
context: web-app
push: ${{ github.ref == 'refs/heads/main' }}
tags: ghcr.io/kevc528/aangs-stocks/web-app:${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
needs: test
deploy:
# Name the Job
name: Deploy latest version of code
# Set the type of machine to run on
runs-on: ubuntu-latest
needs: build
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
# TODO: deploy to AWS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Generate kubeconfig
run: |
aws eks --region us-east-1 update-kubeconfig --name cis188 --role-arn arn:aws:iam::474844133309:role/kevc528 --alias cis188
kubectl config set-context --current --namespace=kevc528
- name: Install into cluster
run: helm upgrade --install -f web-app-values.yaml --set fastapi.tag=${{ github.sha }},environment.email=${{ secrets.EMAIL_ADDRESS }},environment.email_password=${{ secrets.EMAIL_PASSWORD }},environment.jwt_secret=${{ secrets.JWT_SECRET }} app ./helm-app/