Merge pull request #53 from cuappdev/master #10
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: Docker Build & Push and Deploy to prod for score-backend | |
| on: | |
| push: | |
| branches: [release] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| sha_short: ${{ steps.vars.outputs.sha_short }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Get SHA | |
| id: vars | |
| run: echo "sha_short=$(git rev-parse --short release)" >> $GITHUB_OUTPUT | |
| - name: Docker Build & Push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./ | |
| file: ./Dockerfile | |
| push: true | |
| tags: cornellappdev/score:${{ steps.vars.outputs.sha_short }} | |
| cache-from: type=registry,ref=cornellappdev/score:cache | |
| cache-to: type=registry,ref=cornellappdev/score:cache,mode=max | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Remote SSH and Deploy | |
| uses: appleboy/ssh-action@v1.0.3 | |
| env: | |
| IMAGE_TAG: ${{ needs.build.outputs.sha_short }} | |
| with: | |
| host: ${{ secrets.PROD_SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USERNAME }} | |
| key: ${{ secrets.PROD_SERVER_KEY }} | |
| envs: IMAGE_TAG | |
| script: | | |
| docker stack deploy -c docker-compose.yml thestack | |
| docker service update --image cornellappdev/score:${IMAGE_TAG} thestack_app | |
| docker system prune -af |