Merge pull request #3 from favicon-data/dev #7
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: Front Deployment | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: | | |
| docker build \ | |
| --build-arg SPRING_PROFILES_ACTIVE=local \ | |
| -f Dockerfile \ | |
| -t ${{ vars.DOCKERHUB_USERNAME}}/erica-favicon-f:latest . | |
| - name: DockerHub login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME}} | |
| password: ${{ vars.DOCKERHUB_PASSWORD}} | |
| - name: Push Docker image | |
| run: docker push ${{ vars.DOCKERHUB_USERNAME}}/erica-favicon-f:latest | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| docker pull ${{ vars.DOCKERHUB_USERNAME }}/erica-favicon-f:latest | |
| docker rm -f front 2>/dev/null || true | |
| docker run --name front -d -p 80:3000 ${{ vars.DOCKERHUB_USERNAME }}/erica-favicon-f:latest |