-
Notifications
You must be signed in to change notification settings - Fork 16
175 lines (151 loc) · 5.78 KB
/
maven.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CICD with Maven
on:
push:
branches:
- master
pull_request:
branches:
- master
- 'release-**'
jobs:
# Wait for up to a minute for previous run to complete, abort if not done by then
pre-ci:
runs-on: ubuntu-latest
timeout-minutes: 100
outputs:
diff: ${{ steps.git-diff.outputs.diff }}
steps:
- name: 'Block Concurrent Executions'
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 60
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- uses: actions/checkout@v2
# Get source code diff
- uses: technote-space/get-diff-action@v4
id: git-diff
with:
PATTERNS: |
src/**/*.+(java|yml)
FILES: |
pom.xml
build:
needs: pre-ci
# Run only if there are differences in the source code
if: needs.pre-ci.outputs.diff
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:12
# Provide the password for postgres
env:
POSTGRES_PASSWORD: harvest
POSTGRES_USER: harvest
POSTGRES_DB: harvest
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Build with Maven
run: >
mvn
-Dethparser.eth.web3Url="${{secrets.ETH_WEB3}}"
-Dethparser.bsc.web3Url="${{secrets.BSC_WEB3}}"
-Dethparser.matic.web3Url="${{secrets.MATIC_WEB3}}"
-Dethparser.eth.abiProviderKey=${{secrets.ETHERSCAN_TOKEN}}
-Dethparser.bsc.abiProviderKey=${{secrets.BSCSCAN_TOKEN}}
-Dethparser.matic.abiProviderKey=${{secrets.POLYSCAN_TOKEN}}
-Dspring.datasource.url=jdbc:postgresql://localhost:5432/harvest
-Dspring.datasource.username=harvest
-Dspring.datasource.password=harvest
-B package -ff -T 1 --file pom.xml
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/
- name: Publish Unit Test Results
uses: olegnat/publish-unit-test-result-action@v1
if: always()
with:
files: target/surefire-reports/**/*.xml
- name: Publish report to codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
directory: target/site/jacoco/ # optional
name: codecov-ethparser # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
deploy:
needs: [pre-ci, build]
# Run only on push, but after pre-ci and build
if: ${{ always() && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})"
id: extract_branch
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
# Optional, GitHub token
github_token: ${{secrets.GITHUB_TOKEN}}
# Required, workflow file name or ID
workflow: maven.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion::
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
# Or a workflow status:
# "completed", "in_progress", "queued"
# Default: "completed,success"
workflow_conclusion: "completed,success"
# Optional, will get head commit SHA
commit: ${{github.event.pull_request.head.sha}}
# Optional, no need to specify if PR is
#pr: ${{github.event.pull_request.number}}
# Optional, will use the branch
branch: ${{ steps.extract_branch.outputs.branch }}
# Optional, will use specified workflow run
#run_id: 1122334455
# Optional, run number from the workflow
#run_number: 34
# Optional, uploaded artifact name,
# will download all artifacts if not specified
# and extract them in respective subdirectories
# https://github.com/actions/download-artifact#download-all-artifacts
name: dist
# Optional, directory where to extract artifact
path: dist
# Optional, defaults to current repo
#repo: ${{github.repository}}
# Run only on push to release branch
if: ${{ startsWith(steps.extract_branch.outputs.branch, 'release-') }}
- name: Prepare deploy to server
uses: hughcube/[email protected]
with:
ssh_private_key: ${{ secrets.SSH_KEY }}
if: ${{ startsWith(steps.extract_branch.outputs.branch, 'release-') }}
- name: Deploy to ETH server
run: |
export SERVER=ethparser_eth
rsync -rzv -e "ssh -J ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" dist/ ${{secrets.SSH_USER}}@$SERVER:/opt/ethparser
ssh -J ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} ${{secrets.SSH_USER}}@$SERVER "/opt/ethparser/deploy.sh"
if: ${{ startsWith(steps.extract_branch.outputs.branch, 'release-') }}