build-api-image.yml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. name: Build and Push API Image
  2. on:
  3. push:
  4. branches:
  5. - 'main'
  6. - 'deploy/dev'
  7. pull_request:
  8. types: [synchronize, opened, reopened, ready_for_review]
  9. jobs:
  10. build-and-push:
  11. runs-on: ubuntu-latest
  12. if: github.event.pull_request.draft == false
  13. steps:
  14. - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
  15. uses: actions/checkout@v2
  16. with:
  17. persist-credentials: false
  18. - name: Login to Docker Hub
  19. uses: docker/login-action@v2
  20. with:
  21. username: ${{ secrets.DOCKERHUB_USER }}
  22. password: ${{ secrets.DOCKERHUB_TOKEN }}
  23. - name: Build and push Docker image
  24. shell: bash
  25. env:
  26. DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
  27. DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
  28. run: |
  29. /bin/bash .github/workflows/build-api-image.sh
  30. - name: Deploy to server
  31. if: github.ref == 'refs/heads/deploy/dev'
  32. uses: appleboy/ssh-action@v0.1.8
  33. with:
  34. host: ${{ secrets.SSH_HOST }}
  35. username: ${{ secrets.SSH_USER }}
  36. key: ${{ secrets.SSH_PRIVATE_KEY }}
  37. script: |
  38. ${{ secrets.SSH_SCRIPT }}