Skip to content

Commit

Permalink
SOROKA-89 Deploy release (#13)
Browse files Browse the repository at this point in the history
* Deploy release

* Rename default branch to `master` in actions
  • Loading branch information
dice4x4 authored Jun 22, 2022
1 parent 5404bf2 commit 39cd692
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
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

0 comments on commit 39cd692

Please sign in to comment.