-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (87 loc) · 2.85 KB
/
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
98
99
100
101
102
103
104
105
name: CI/CD Pipeline
# run it locally: act --secret-file .secrets --env-file .env
on:
push:
branches:
- main
- feature/deployment
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install Poetry
run: |
pip install poetry
- name: Install dependencies
run: |
cd backend-python
poetry install
- name: Run pytest
run: |
cd backend-python
poetry run pytest -k "not mediacloud and not proxied" # TODO: un-skip tests
env:
MEDIACLOUD_API_TOKEN: ${{ secrets.MEDIACLOUD_API_TOKEN }}
ACLED_EMAIL: ${{ secrets.ACLED_EMAIL }}
ACLED_KEY: ${{ secrets.ACLED_KEY }}
ZENROWS_API_KEY: ${{ secrets.ZENROWS_API_KEY }}
build-and-push:
needs: test
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker image
run: |
docker build \
-t socialchangelab/media-impact-monitor:${{ github.sha }} \
-t socialchangelab/media-impact-monitor:latest \
.
- name: Push Docker image
run: docker push --all-tags socialchangelab/media-impact-monitor
deploy:
# this pipeline does not work locally with act
# due to some issues with Azure CLI login
needs: build-and-push
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Azure CLI
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.4
- name: Terraform Init
run: terraform init
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
- name: Terraform Apply
run: terraform apply -auto-approve
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
TF_VAR_DOCKER_IMAGE: socialchangelab/media-impact-monitor:${{ github.sha }}
TF_VAR_MEDIACLOUD_API_TOKEN: ${{ secrets.MEDIACLOUD_API_TOKEN }}
TF_VAR_ACLED_EMAIL: ${{ secrets.ACLED_EMAIL }}
TF_VAR_ACLED_KEY: ${{ secrets.ACLED_KEY }}
TF_VAR_ZENROWS_API_KEY: ${{ secrets.ZENROWS_API_KEY }}