This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 1.94 KB
/
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
70
71
72
73
74
75
76
77
78
79
name: CI
env:
IMAGE_NAME: xiangronglin/novel-worker
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- run: mvn install
- name: Prepare for saving docker image
if: github.event_name == 'push'
run: mkdir docker
- name: Save docker image as tar
if: github.event_name == 'push'
run: docker save ${{ env.IMAGE_NAME }} > docker/image.tar
- name: Upload docker image tar as artifact
uses: actions/upload-artifact@v2
if: github.event_name == 'push'
with:
name: docker-image
path: docker
retention-days: 1
publish-docker:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
steps:
- name: Download docker image tar from artifacts
uses: actions/download-artifact@v2
with:
name: docker-image
path: docker
- name: Load docker image from tar
run: |
cd docker
docker load < image.tar
- name: Docker login
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Docker push
run: docker push ${{ env.IMAGE_NAME }}
- name: Trigger deploy
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" \
https://api.github.com/repos/NovelService/NovelDeployer/dispatches \
-d '{"event_type":"deploy"}'