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

[ISSUE-#72] CI/CD 파이프라인 #77

Merged
merged 4 commits into from
Sep 26, 2023
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
43 changes: 43 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy dev

on:
workflow_run:
workflows:
- Build and Push Docker Image for DEV
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_REPO: liberty52/liberty52-admin-server

steps:
- name: Get latest Release tag
id: latest-tag
uses: robinraju/[email protected]
with:
latest: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set Docker Image Name
id: new-docker-image
run: echo "::set-output name=image_name::$DOCKER_REGISTRY/$DOCKER_REPO:dev-${{ steps.latest-tag.outputs.tag_name }}"

- name: Deploy AWS EC2 dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP_DEV }}
username: ${{ secrets.REMOTE_SSH_ID_DEV }}
key: ${{ secrets.REMOTE_SSH_KEY_DEV }}
port: ${{ secrets.REMOTE_SSH_PORT_DEV }}
script: |
echo ${{ secrets.GTOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
sudo docker pull ${{ steps.new-docker-image.outputs.image_name }}
container_name=$(sudo docker ps | grep liberty52 | awk '{print $NF}')
sudo docker stop $container_name
sudo docker run -d -p 8080:8080 ${{ steps.new-docker-image.outputs.image_name }}
30 changes: 30 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy prod

on:
workflow_run:
workflows:
- "Build and Push Docker Image for PROD"
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
DOCKER_IMAGE: ghcr.io/liberty52/liberty52-admin-server:prod-${{ github.sha }}

steps:
- name: Deploy AWS EC2 dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP_PROD }}
username: ${{ secrets.REMOTE_SSH_ID_PROD }}
key: ${{ secrets.REMOTE_SSH_KEY_PROD }}
port: ${{ secrets.REMOTE_SSH_PORT_PROD }}
script: |
echo ${{ secrets.GTOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin
sudo docker pull $DOCKER_IMAGE
container_name=$(sudo docker ps | grep liberty52 | awk '{print $NF}')
sudo docker stop $container_name
sudo docker run -d -p 8080:8080 $DOCKER_IMAGE
Loading