Skip to content

Commit 39cd692

Browse files
authored
SOROKA-89 Deploy release (#13)
* Deploy release * Rename default branch to `master` in actions
1 parent 5404bf2 commit 39cd692

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed

.github/workflows/deploy-release.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and deploy release
2+
3+
concurrency: production
4+
5+
on:
6+
release:
7+
types:
8+
- released
9+
branches:
10+
- master
11+
tags:
12+
- 'v*'
13+
env:
14+
USERNAME: deploy
15+
HOST: wunder-kammer.ru
16+
PORT: 22
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
NAME: soroka-backend-prod
20+
21+
jobs:
22+
deploy:
23+
name: Build and Deploy release
24+
runs-on: ubuntu-latest
25+
env:
26+
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
27+
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
28+
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
29+
DB_PORT: ${{ secrets.DB_PORT }}
30+
DB_HOST: ${{ secrets.DB_HOST }}
31+
DB_DIALECT: postgres
32+
SERVER_PORT: 8000
33+
ACCESS_TOKEN_LIFETIME: 300000
34+
REFRESH_TOKEN_LIFETIME: 3600000
35+
steps:
36+
- name: Checkout latest
37+
uses: actions/checkout@v3
38+
39+
- name: Log into registry ${{ env.REGISTRY }}
40+
uses: docker/login-action@v2
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata (tags, labels) for Docker
47+
id: meta
48+
uses: docker/metadata-action@v4
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
flavor: |
52+
latest=true
53+
prefix=
54+
suffix=
55+
tags: |
56+
type=semver,pattern={{version}}
57+
58+
- name: Build and push Docker image
59+
id: build-and-push
60+
uses: docker/build-push-action@v3
61+
with:
62+
context: .
63+
push: true
64+
tags: ${{ steps.meta.outputs.tags }}
65+
66+
- name: executing remote ssh commands using ssh key
67+
uses: appleboy/ssh-action@master
68+
with:
69+
host: ${{ env.HOST }}
70+
username: ${{ env.USERNAME }}
71+
key: ${{ secrets.WNDRKMR_SSH_KEY }}
72+
port: ${{ env.PORT }}
73+
script: |
74+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u dice4x4 --password-stdin
75+
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
76+
docker rm -f ${{ env.NAME }}
77+
docker run -dp 8084:8000 --network wndrnet --name ${{ env.NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
78+
docker logout
79+

.github/workflows/deploy-staging.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
types:
88
- closed
99
branches:
10-
- main
10+
- master
1111
env:
1212
USERNAME: deploy
1313
HOST: wunder-kammer.ru

.github/workflows/docker-image.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build Docker Image
22

33
on:
44
pull_request:
5-
branches: [ "main" ]
5+
branches: [ "master" ]
66
types: ["opened", "reopened", "synchronize"]
77
tags: [ 'v*.*.*' ]
88

0 commit comments

Comments
 (0)