-
Notifications
You must be signed in to change notification settings - Fork 5
174 lines (149 loc) · 5.93 KB
/
build.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
name: Java Maven Build, Test, and Publish
on:
push:
branches:
- feature*
- bugfix*
- develop
tags: [ 'v.*.*.*' ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
jobs:
maven-build:
name: Maven Build and Test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Install linux deps
run: sudo apt-get install -y libcurl4-openssl-dev
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install python dependencies
run: pip install jep==3.9 # Install the jep library
- name: Set JEP_LIBRARY_PATH environment variable
run: |
echo "JEP_LIBRARY_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')/jep" >> $GITHUB_ENV
- name: test
run: |
echo $JEP_LIBRARY_PATH
ls $JEP_LIBRARY_PATH
- name: Install deps
run: Rscript -e 'install.packages(c("httr", "jsonlite", "remotes"))'
- name: Install metadig
run: Rscript -e 'remotes::install_github("nceas/metadig-r")'
- name: Create /opt/local directory
run: mkdir -p /opt/local/metadig
- name: Copy properties file to /opt/local
run: cp helm/metadig-controller/config.dev/metadig.properties /opt/local/metadig/metadig.properties
- name: Extract Maven project version
run: echo "version="$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT
id: get_version
#- name: Show extracted Maven project version
#run: echo "Version from pom: " ${{ steps.get_version.outputs.version }}
- name: Build and Test
run: mvn --batch-mode --update-snapshots test
- name: Package
run: mvn --batch-mode --update-snapshots -DskipTests=true package
- uses: actions/cache@v3
with:
path: .
key: builddir-${{ github.run_id }}
docker-publish:
name: Docker Build and Publish
if: github.ref_name == 'develop' || startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref_name, 'feature')
needs: maven-build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/cache@v3
with:
path: .
key: builddir-${{ github.run_id }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# SCHEDULER Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for scheduler
id: metasched
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/nceas/metadig-scheduler
# SCHEDULER Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push scheduler image
uses: docker/build-push-action@v3
with:
context: .
file: Docker/metadig-scheduler/Dockerfile
build-args: |
TAG=${{ steps.metasched.outputs.labels['org.opencontainers.image.version'] }}
ENGINE_TAG=${{needs.maven-build.outputs.version}}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metasched.outputs.tags }}
labels: ${{ steps.metasched.outputs.labels }}
# SCORER Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for scorer
id: metascor
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/nceas/metadig-scorer
# SCORER Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push scorer image
uses: docker/build-push-action@v3
with:
context: .
file: Docker/metadig-scorer/Dockerfile
build-args: |
TAG=${{ steps.metascor.outputs.labels['org.opencontainers.image.version'] }}
ENGINE_TAG=${{needs.maven-build.outputs.version}}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metascor.outputs.tags }}
labels: ${{ steps.metascor.outputs.labels }}
# WORKER Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata for worker
id: metawor
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/nceas/metadig-worker
# WORKER Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push worker image
uses: docker/build-push-action@v3
with:
context: .
file: Docker/metadig-worker/Dockerfile
build-args: |
TAG=${{ steps.metawor.outputs.labels['org.opencontainers.image.version'] }}
ENGINE_TAG=${{needs.maven-build.outputs.version}}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metawor.outputs.tags }}
labels: ${{ steps.metawor.outputs.labels }}