build-api-image.yml 1.1 KB

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