This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Refactors onibus data refresh process #8
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: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ secrets.DOCKER_USERNAME }}/api-onibusbh:latest | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| docker stop api-onibusbh || true | |
| docker rm api-onibusbh || true | |
| docker pull ${{ secrets.DOCKER_USERNAME }}/api-onibusbh:latest | |
| docker run -d \ | |
| --name api-onibusbh \ | |
| -p 8080:8080 \ | |
| -e SPRING_PROFILES_ACTIVE=prod \ | |
| -e MONGO_HOST=${{ secrets.MONGO_HOST }} \ | |
| -e MONGO_PORT=${{ secrets.MONGO_PORT }} \ | |
| -e MONGO_DATABASE=${{ secrets.MONGO_DATABASE }} \ | |
| -e MONGO_USERNAME=${{ secrets.MONGO_USERNAME }} \ | |
| -e MONGO_PASSWORD=${{ secrets.MONGO_PASSWORD }} \ | |
| ${{ secrets.DOCKER_USERNAME }}/api-onibusbh:latest |