-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (110 loc) · 4.26 KB
/
release-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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: 'Build and Deploy server'
on:
release:
types: [ published ]
workflow_dispatch:
jobs:
test:
name: 'Test before deploy'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: cache poetry install
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.2.2-0
- uses: snok/install-poetry@v1
with:
version: 1.2.2
virtualenvs-create: true
virtualenvs-in-project: true
- name: cache deps
id: cache-deps
uses: actions/cache@v2
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}
- run: poetry install --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'
- run: poetry run pip install setuptools
- name: Run tests
run: poetry run python manage.py test
env:
DEBUG: True
build:
name: 'Build & Publish'
runs-on: ubuntu-latest
needs: [ test ]
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
- 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 Registry"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/procollab-github/api
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Build and push container
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: run on server
uses: garygrossgarten/github-action-ssh@release
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
command: |
cd /home/app/procollab-backend &&
docker container prune -f &&
docker image prune -a -f &&
docker compose -f docker-compose.prod-ci.yml -p prod pull &&
rm -f .env &&
touch .env &&
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> .env &&
echo "DATABASE_NAME=${{ secrets.DATABASE_NAME }}" >> .env &&
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env &&
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> .env &&
echo "DATABASE_HOST=${{ secrets.DATABASE_HOST }}" >> .env &&
echo "DATABASE_PORT=${{ secrets.DATABASE_PORT }}" >> .env &&
echo "EMAIL_USER=${{ secrets.EMAIL_USER }}" >> .env &&
echo "EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}" >> .env &&
echo "EMAIL_HOST=${{ secrets.EMAIL_HOST }}" >> .env &&
echo "EMAIL_PORT=${{ secrets.EMAIL_PORT }}" >> .env &&
echo "SELECTEL_ACCOUNT_ID=${{ secrets.SELECTEL_ACCOUNT_ID }}" >> .env &&
echo "SELECTEL_CONTAINER_NAME=${{ secrets.SELECTEL_CONTAINER_NAME }}" >> .env &&
echo "SELECTEL_CONTAINER_PASSWORD=${{ secrets.SELECTEL_CONTAINER_PASSWORD }}" >> .env &&
echo "SELECTEL_CONTAINER_USERNAME=${{ secrets.SELECTEL_CONTAINER_USERNAME }}" >> .env &&
echo "CLICKUP_API_TOKEN=${{ secrets.CLICKUP_API_TOKEN }}" >> .env &&
echo "CLICKUP_SPACE_ID=${{ secrets.CLICKUP_SPACE_ID }}" >> .env &&
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env &&
docker compose -f docker-compose.prod-ci.yml -p prod up -d