forked from ICIJ/datashare
-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (123 loc) · 4.25 KB
/
Copy pathbuild_and_push.yaml
File metadata and controls
149 lines (123 loc) · 4.25 KB
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
name: Build and Push Datashare Image
on:
push:
tags:
- '*.*.*'
env:
MAVEN_OPTS: "-Xms512m -Xmx512m -Xss10M"
jobs:
build-frontend:
runs-on: ubuntu-latest
outputs:
frontend-artifacts-path: ${{ steps.build_artifacts.outputs.distribution-path }}
steps:
- name: Checkout frontend repository
uses: actions/checkout@v4
with:
repository: 'icij/datashare-client'
ref: 'main'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Build frontend for distribution
run: npm run build
- name: Upload frontend distribution
uses: actions/upload-artifact@v4
with:
name: frontend-distribution
path: dist
build-backend:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: datashare_liquibase
POSTGRES_USER: dstest
POSTGRES_PASSWORD: test
ports:
- 5432:5432
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
env:
discovery.type: "single-node"
discovery.seed_hosts: "elasticsearch:9200"
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ports:
- 9200:9200
- 9300:9300
redis:
image: redis:latest
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from pom.xml
id: get_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "::set-output name=VERSION::$VERSION"
- name: Print version
run: echo "The version is ${{ steps.get_version.outputs.VERSION }}"
- name: Wait for PostgreSQL to be ready
run: |
until PGPASSWORD=test psql -h localhost -U dstest -d datashare_liquibase -c '\q'; do
>&2 echo "Postgres is still unavailable - sleeping"
sleep 1
done
>&2 echo "Postgres is up - executing command"
- name: Run init script on PostgreSQL
run: PGPASSWORD=test psql -h localhost -U dstest -d datashare_liquibase -a -f ./datashare-db/scr/init.sql
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Set up Maven
uses: stCarolas/setup-maven@v4
with:
maven-version: 3.6.3
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Validate project
run: mvn validate
- name: Install commons-test
run: mvn -pl commons-test -am install -DskipTests
- name: Update database
run: mvn -pl datashare-db liquibase:update
- name: Build datashare-app and datashare-nlp-corenlp
run: mvn -pl datashare-app,datashare-nlp-corenlp -am install -Dmaven.test.skip=true -Dgpg.skip=true
- name: Download frontend artifacts
uses: actions/download-artifact@v4
with:
name: frontend-distribution
path: app
- name: Package everything
run: mvn -pl datashare-dist package
- name: lowercase github.repository
run: |
echo "IMAGE_REPO=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./datashare-dist/target/datashare-dist-${{ steps.get_version.outputs.VERSION }}-docker
file: ./datashare-dist/target/datashare-dist-${{ steps.get_version.outputs.VERSION }}-docker/Dockerfile
push: true
tags: ghcr.io/${{ env.IMAGE_REPO }}:${{ github.ref_name }}
platforms: linux/amd64,linux/arm64