Skip to content

Commit d539a94

Browse files
committed
new test workflow
1 parent 235f6fc commit d539a94

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

.github/workflows/deploy-test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Build & Push and Deploy to prod for eatery-prod
2+
3+
on:
4+
push:
5+
branches: [test]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKER_USERNAME }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
25+
- name: Get SHA
26+
id: vars
27+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: Docker Build & Push
30+
uses: docker/build-push-action@v5
31+
with:
32+
context: ./
33+
file: ./Dockerfile
34+
push: true
35+
tags: cornellappdev/eatery-test:${{ steps.vars.outputs.sha_short }}
36+
37+
- name: Remote SSH and Deploy
38+
uses: appleboy/ssh-action@v1.0.3
39+
env:
40+
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
41+
with:
42+
host: ${{ secrets.TEST_SERVER_HOST }}
43+
username: ${{ secrets.SERVER_USERNAME }}
44+
key: ${{ secrets.TEST_SERVER_KEY }}
45+
script: |
46+
export IMAGE_TAG=${{ steps.vars.outputs.sha_short }}
47+
cd docker-compose
48+
docker stack rm thestack
49+
sleep 20s
50+
docker stack deploy -c docker-compose.yml thestack
51+
yes | docker system prune -a

0 commit comments

Comments
 (0)