Skip to content

Commit

Permalink
infra: cicd monitor 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoya324 committed Dec 5, 2024
1 parent c28c1be commit 22ca82f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,43 +153,3 @@ jobs:
sudo docker pull ${{ secrets.DOCKER_REPO }}:develop-${{ github.run_number }}
sudo docker-compose -f docker-compose.yml up -d
sudo docker image prune -f
deploy-monitor:
runs-on: ubuntu-latest

if: github.event_name == 'workflow_dispatch'

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'ap-northeast-2'

- name: Copy docker-compose-monitor.yml into monitor instance
uses: appleboy/scp-action@master
with:
host: ${{ secrets.MONITOR_PUBLIC_DNS }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PEM_KEY }}
source: "docker/docker-compose-monitor.yml"
target: "/home/${{ secrets.MONITOR_USERNAME }}/docker/docker-compose-monitor.yml"
strip_components: 3
overwrite: true
debug: true

- name: Deploy to EC2 monitor server
uses: appleboy/[email protected]
with:
host: ${{ secrets.MONITOR_PUBLIC_DNS }}
username: ${{ secrets.MONITOR_USERNAME }}
key: ${{ secrets.MONITOR_PEM_KEY }}
script: |
cd /home/${{ secrets.MONITOR_USERNAME }}
echo ${{ secrets.DOCKER_PASSWORD }} | sudo docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
sudo docker-compose -f docker-compose-monitor.yml up -d
sudo docker image prune -f
46 changes: 46 additions & 0 deletions .github/workflows/monitoring-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Monitoring CI/CD Workflow

on:
workflow_dispatch:

permissions:
contents: read

jobs:
deploy-monitor:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'ap-northeast-2'

- name: Copy docker-compose-monitor.yml into monitor instance
uses: appleboy/scp-action@master
with:
host: ${{ secrets.MONITOR_PUBLIC_DNS }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PEM_KEY }}
source: "docker/docker-compose-monitor.yml"
target: "/home/${{ secrets.USERNAME }}/docker/docker-compose-monitor.yml"
strip_components: 3
overwrite: true
debug: true

- name: Deploy to EC2 monitor server
uses: appleboy/[email protected]
with:
host: ${{ secrets.MONITOR_PUBLIC_DNS }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PEM_KEY }}
script: |
cd /home/${{ secrets.USERNAME }}
echo ${{ secrets.DOCKER_PASSWORD }} | sudo docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
sudo docker-compose -f docker-compose-monitor.yml up -d
sudo docker image prune -f

0 comments on commit 22ca82f

Please sign in to comment.