fix: remove and rerun docker container #17
This file contains 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 API | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: npm ci | |
- run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- run: npx nx run api:image:build | |
- run: npx nx run api:image:push | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
port: ${{ secrets.SSH_PORT }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_KEY_PASSPHRASE }} | |
script: | | |
docker pull gatherloop/gatherloop-pos-api | |
docker container stop gatherloop-pos-api | |
docker container remove gatherloop-pos-api | |
docker run --name gatherloop-pos-api --network gatherloop-pos-network -e DB_USERNAME=${{ secrets.DB_USERNAME }} -e "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" -e DB_NAME=${{ secrets.DB_NAME }} -e DB_HOST=${{ secrets.DB_HOST }} -e DB_PORT=${{ secrets.DB_PORT }} -e PORT=${{ secrets.API_PORT }} -d gatherloop/gatherloop-pos-api | |
docker image prune -a |