Merge pull request #80 from collabberry/ui-chart-fix #36
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: Docker Build and AWS Deploy | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: dev-aws-env | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| run: | | |
| docker compose -f docker-compose.ci-dev.yml build | |
| docker compose -f docker-compose.ci-dev.yml push | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| environment: dev-aws-env | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install SSH key | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts | |
| - name: Copy the compose file to EC2 | |
| run: | | |
| scp -i ~/.ssh/id_rsa docker-compose.ci-dev.yml ${{ vars.EC2_USERNAME }}@${{ secrets.EC2_HOST }}:/home/admin/deployment/docker-compose.fe.yml | |
| - name: Deploy to EC2 | |
| run: | | |
| ssh -i ~/.ssh/id_rsa ${{ vars.EC2_USERNAME }}@${{ secrets.EC2_HOST }} ' | |
| cd /home/admin/deployment/ && | |
| docker compose -f docker-compose.fe.yml pull && | |
| docker compose -f docker-compose.fe.yml up -d | |
| ' | |
| - name: Clean up SSH key | |
| if: always() | |
| run: rm -rf ~/.ssh |