-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (52 loc) · 1.98 KB
/
Backend-CI.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
name: Backend CI
on:
pull_request:
branches: [ "be/develop" ]
push:
branches: [ "be/develop" ]
permissions:
contents: read
jobs:
build:
env:
working-directory: ./backend/pokerogue
docker-directory: ./backend/pokerogue/docker
runs-on: self-hosted
steps:
- name: Change permission
run: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/2024-pokerogue-helper
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.ACTION_TOKEN }}
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run Test
run: ./gradlew clean test
working-directory: ${{ env.working-directory }}
- name: Build with Gradle
run: ./gradlew bootJar
working-directory: ${{ env.working-directory }}
- name: Docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_SERVER_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile ./backend/pokerogue
docker push ${{ secrets.DOCKER_SERVER_IMAGE }}
docker build -t ${{ secrets.DOCKER_NGINX_IMAGE }} -f ./backend/pokerogue/docker/Dockerfile-nginx ./backend/pokerogue/docker
docker push ${{ secrets.DOCKER_NGINX_IMAGE }}
- name: Deploy
run: |
cd /home/ubuntu
sudo touch docker-compose.yml
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null
sudo chmod 666 /var/run/docker.sock
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_SERVER_IMAGE }}
sudo docker pull ${{ secrets.DOCKER_NGINX_IMAGE }}
docker-compose -f docker-compose.yml up -d
docker image prune -f