-
Notifications
You must be signed in to change notification settings - Fork 24
70 lines (62 loc) · 2.13 KB
/
backend-cd.yml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Backend Continuous Deployment
on:
push:
paths:
- '.github/workflows/backend-cd.yml'
- 'api/**'
- '!api/.gitignore'
- '!api/README.md'
- '.gitmodules'
branches:
- 'master'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Docker login
env:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: docker login https://ghcr.io -u ${username} -p ${password}
- name: Build Third Party Image
env:
DOCKER_BUILDKIT: 1
run: |
cd ./api
if git diff --exit-code ../.gitmodules || git diff --exit-code ./third-party || git diff --exit-code ./Dockerfile
then
docker build . -t ghcr.io/memelabs/rustla2/rustla2-api:thirdPartyBase --build-arg APP_ENV=full --target full-build
docker push ghcr.io/memelabs/rustla2/rustla2-api:thirdPartyBase
else
return 0
fi
- name: Build API image
env:
DOCKER_BUILDKIT: 1
run: cd ./api && docker build . -t ghcr.io/memelabs/rustla2/rustla2-api:stable
- name: Download container structure test binary
uses: fnkr/github-action-git-bash@v1
with:
args: "wget -O ./api/container-structure-test https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64"
- name: Chmod
uses: fnkr/github-action-git-bash@v1
with:
args: "chmod +x ./api/container-structure-test"
- name: Test image
uses: fnkr/github-action-git-bash@v1
with:
args: "./api/container-structure-test test --image ghcr.io/memelabs/rustla2/rustla2-api:stable --config ./api/container_test.yaml"
- name: Docker push
run: docker push ghcr.io/memelabs/rustla2/rustla2-api:stable
- name: ssh-deploy for rustla backend
uses: appleboy/ssh-action@122f35dca5c7a216463c504741deb0de5b301953
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
./hooks/rustla2-api.sh