Rewrite iOS course backend #7
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: Production Deployment | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| jobs: | |
| setup-build-publish-deploy: | |
| name: Setup, Build, Publish, and Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Auth Docker | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Get SHA | |
| id: vars | |
| run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
| - name: Build | |
| run: |- | |
| docker build --tag "cornellappdev/ios-course-backend:${{ steps.vars.outputs.sha_short }}" . | |
| - name: Publish | |
| run: |- | |
| docker push "cornellappdev/ios-course-backend:${{ steps.vars.outputs.sha_short }}" | |
| - name: SSH & Deploy | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.PRIVATE_KEY }} | |
| script: | | |
| export IOS_COURSE_IMG_TAG="${{ steps.vars.outputs.sha_short }}" | |
| cd docker-compose | |
| yes | docker system prune --all --volumes | |
| docker-compose down --remove-orphans | |
| docker-compose up -d --build |