Production deployment #421
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Production deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref (Optional) | |
required: false | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
deploy: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Login to Docker hub | |
run: docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build plugin | |
run: ${{ secrets.ENABLE_PLUGIN }} | |
- name: Build docker | |
run: > | |
docker build -t 4programmers/coyote:$GITHUB_SHA -t 4programmers/coyote:latest -f docker/coyote/Dockerfile \ | |
--build-arg FRONTEND_SENTRY_DSN=${{ secrets.FRONTEND_SENTRY_DSN }} \ | |
--build-arg VAPID_PUBLIC_KEY=${{ secrets.VAPID_PUBLIC_KEY }} \ | |
--build-arg SENTRY_API_KEY=${{ secrets.SENTRY_API_KEY }} \ | |
--build-arg RELEASE=$GITHUB_RUN_ID . | |
- name: Push to registry | |
run: docker push -a 4programmers/coyote | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PRODUCTION_IP }} | |
username: ${{ secrets.PRODUCTION_LOGIN }} | |
key: ${{ secrets.PRODUCTION_KEY }} | |
port: 22 | |
envs: GITHUB_SHA | |
script: | | |
sudo docker service update --image 4programmers/coyote:$GITHUB_SHA coyote_php | |
sudo docker service update --image 4programmers/coyote:$GITHUB_SHA coyote_worker | |
sudo docker service update --image 4programmers/coyote:$GITHUB_SHA coyote_cron | |
- name: Sentry Release Backend | |
uses: getsentry/[email protected] | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: coyote | |
SENTRY_PROJECT: backend | |
with: | |
# Set the environment for this release. E.g. "production" or "staging". Omit to skip adding deploy to release. | |
environment: production | |
# When the flag is set, command will not fail and just exit silently if no new commits for a given release have been found. | |
ignore_empty: "true" | |
ignore_missing: "true" | |
projects: backend |