Chore: (FN-38) develop CD 추가 (#1) #1
This file contains hidden or 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: develop-cd.yml | |
| on: | |
| push: | |
| branches: [develop] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| - name: Extract Docker image metadata (short SHA) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ secrets.DOCKERHUB_USERNAME }}/flipnote-app | |
| tags: type=sha,format=short | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: false | |
| file: ./Dockerfile | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Login to DockerHub | |
| run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin | |
| - name: Push Docker image | |
| run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/flipnote-app:${{ steps.meta.outputs.version }} | |
| - name: Deploy to EC2 (Blue/Green) | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| script: | | |
| export IMAGE_TAG=${{ steps.meta.outputs.version }} | |
| bash ~/deploy/deploy-flipnote.sh |