-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (51 loc) · 1.69 KB
/
deploy-dev.yml
File metadata and controls
54 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Docker Build & Push and Deploy to dev for score-backend
on:
push:
branches: [master]
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 HEAD)" >> $GITHUB_OUTPUT
- name: Docker Build & Push
uses: docker/build-push-action@v6
with:
context: ./
file: ./Dockerfile
push: true
tags: cornellappdev/score-dev:${{ steps.vars.outputs.sha_short }}
cache-from: type=registry,ref=cornellappdev/score-dev:cache
cache-to: type=registry,ref=cornellappdev/score-dev: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.DEV_SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.DEV_SERVER_KEY }}
envs: IMAGE_TAG
script: |
docker stack deploy -c docker-compose.yml thestack
docker service update --image cornellappdev/score-dev:${IMAGE_TAG} thestack_app
docker system prune -af