Repository navigation
fix: modify timestamp handling in marketplace #28
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: | |
| - develop | |
| paths: | |
| - 'backend/**' | |
| - '.github/workflows/backend-prod.yaml' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./backend | |
| push: true | |
| tags: ghcr.io/lambdaiith/dashboard:latest | |
| - name: SSH and deploy on EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| set -e | |
| cd ~/Dashboard | |
| echo ${{ secrets.GITHUB_TOKEN }} | sudo docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| echo "Stopping and removing all containers..." | |
| sudo docker rm -f $(sudo docker ps -aq) || true | |
| echo "Cleaning up unused Docker images and volumes..." | |
| sudo docker image prune -a -f | |
| sudo docker volume prune -f | |
| echo "Pulling and deploying the latest Docker image..." | |
| sudo docker compose pull | |
| sudo docker compose up -d | |
| echo "Pulling and deploying latest image..." | |
| sudo docker compose pull | |
| sudo docker compose down | |
| sudo docker compose up -d |