-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (58 loc) · 2.25 KB
/
ci.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
name: CI/CD
on: [push]
permissions: read-all
jobs:
Test:
runs-on: [ubuntu-latest]
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The repository has been cloned to the runner."
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Generate .env from GitHub secrets
run: python env_json_to_dotenv.py SECRETS_CONTEXT
- name: Build and run tests 🧪
run: |
docker build -t nycmesh-support-bot-test .
docker run -v "$PWD/.env:/app/.env" --rm nycmesh-support-bot-test pytest
Build:
runs-on: [self-hosted, daniel-server]
needs: Test
if: github.ref == 'refs/heads/main'
steps:
- name: Login to Dockerhub
run: docker login --username=${{ secrets.DOCKER_USERNAME }} --password=${{ secrets.DOCKER_PASSWORD }}
- name: Check out repository code
uses: actions/checkout@v3
- name: Build image
run: docker build . -t andybaumgar/nycmesh-support-bot:$GITHUB_SHA
- name: Push to dockerhub
run: docker push andybaumgar/nycmesh-support-bot:$GITHUB_SHA
Deploy:
runs-on: [self-hosted, daniel-server]
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
needs: [Test, Build]
if: github.ref == 'refs/heads/main'
steps:
- name: Pull from Dockerhub
run: docker pull andybaumgar/nycmesh-support-bot:$GITHUB_SHA
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Generate .env from GitHub secrets
run: python env_json_to_dotenv.py SECRETS_CONTEXT
- name: Stop old container and run
run: |
docker stop nycmesh-support-bot || true
docker rm nycmesh-support-bot || true
docker run -d --name nycmesh-support-bot -v "$PWD/.env:/app/.env" --restart unless-stopped andybaumgar/nycmesh-support-bot:$GITHUB_SHA supportbot-server --channel-ids "C679UKBUK" --channel-ids "C045QM9TDMZ" --nn-property-id "XfBTK3QZ1S"
- name: Print startup output
run: |
sleep 5
docker logs nycmesh-support-bot