Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOROKA-89 Deploy release #13

Merged
merged 2 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and deploy release

concurrency: production

on:
release:
types:
- released
branches:
- master
tags:
- 'v*'
env:
USERNAME: deploy
HOST: wunder-kammer.ru
PORT: 22
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NAME: soroka-backend-prod

jobs:
deploy:
name: Build and Deploy release
runs-on: ubuntu-latest
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_DIALECT: postgres
SERVER_PORT: 8000
ACCESS_TOKEN_LIFETIME: 300000
REFRESH_TOKEN_LIFETIME: 3600000
steps:
- name: Checkout latest
uses: actions/checkout@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=true
prefix=
suffix=
tags: |
type=semver,pattern={{version}}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ secrets.WNDRKMR_SSH_KEY }}
port: ${{ env.PORT }}
script: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u dice4x4 --password-stdin
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker rm -f ${{ env.NAME }}
docker run -dp 8084:8000 --network wndrnet --name ${{ env.NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker logout

2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types:
- closed
branches:
- main
- master
env:
USERNAME: deploy
HOST: wunder-kammer.ru
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Docker Image

on:
pull_request:
branches: [ "main" ]
branches: [ "master" ]
types: ["opened", "reopened", "synchronize"]
tags: [ 'v*.*.*' ]

Expand Down