-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (60 loc) · 2.16 KB
/
deploy-dev-was.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
71
name: Continuous deployment - development WAS
on:
push:
branches:
- develop
env:
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository }}
DOCKER_IMAGE_TAG: latest
DOCKER_CONTAINER_NAME: soolsool-was
DOCKER_ENV_OPTION: --env-file=/home/ubuntu/soolsool-docker.env
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'corretto'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: bootJar
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build Docker image and push to ghcr
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}
deploy:
needs: build
runs-on: [ self-hosted, soolsool-dev-runner ]
steps:
- name: Login to GitHub container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Docker run
run: |
docker pull ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }} && \
if docker ps -a | grep -q ${{ env.DOCKER_CONTAINER_NAME }} ; then \
docker stop ${{ env.DOCKER_CONTAINER_NAME }} && \
docker rm ${{ env.DOCKER_CONTAINER_NAME }} ;
fi && \
docker run -d -p 8080:8080 --restart=always --name=${{ env.DOCKER_CONTAINER_NAME }} ${{ env.DOCKER_ENV_OPTION }} ${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }} && \
docker rmi $(docker image ls | awk '$1 == "${{ env.DOCKER_IMAGE_NAME }}" {print $3}') || true