Deploy to Production #3
Workflow file for this run
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: Deploy to Production | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
description: "semver without v" | |
required: true | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: production | |
env: | |
IMAGE_FULL_URL: ${{ secrets.DOCKERHUB_USERNAME }}/gdsc-server:${{ github.event.inputs.semver }} | |
steps: | |
- name: Deploy to EC2 Server | |
uses: appleboy/ssh-action@master | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_PRIVATE_KEY }} | |
envs: IMAGE_FULL_URL # docker-compose.yml 에서 사용할 환경 변수 | |
script: | | |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
docker pull ${{ env.IMAGE_FULL_URL }} | |
docker-compose up -d | |
docker image prune -a -f | |
# Slack 알림 | |
- name: Send Deploy Result to Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
SLACK_USERNAME: 둘기봇 | |
SLACK_ICON: https://github.com/GDSC-Hongik/gdsc-server/assets/91878695/1d3861bd-672d-4ee7-8de4-f06c9a06f514 | |
SLACK_TITLE: "Deploy Summary - Production" | |
SLACK_MESSAGE: Manually deployed with `${{ env.IMAGE_FULL_URL }}` |