Skip to content

Commit 54265c6

Browse files
committed
collapse all Docker builds into a single PR check - second try
1 parent 02a5fb2 commit 54265c6

File tree

3 files changed

+125
-90
lines changed

3 files changed

+125
-90
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- develop
88
tags:
99
- "v*.*.*"
10+
pull_request:
1011
workflow_dispatch:
1112
schedule:
1213
- cron: "0 0 * * *"
@@ -31,6 +32,7 @@ jobs:
3132
env:
3233
R_VERSION: ${{ needs.rversion.outputs.R_VERSION }}
3334
DEFAULT_R_VERSION: 4.4
35+
PUSH: ${{ github.event_name != 'pull_request' }}
3436
steps:
3537
- uses: actions/checkout@v4
3638

@@ -42,13 +44,14 @@ jobs:
4244
uses: docker/setup-buildx-action@v3
4345

4446
- name: Login to DockerHub
45-
if: ${{ secrets.DOCKERHUB_USERNAME != '' }}
47+
if: env.PUSH == 'true' && ${{ secrets.DOCKERHUB_USERNAME != '' }}
4648
uses: docker/login-action@v3
4749
with:
4850
username: ${{ secrets.DOCKERHUB_USERNAME }}
4951
password: ${{ secrets.DOCKERHUB_PASSWORD }}
5052

5153
- name: Login to GitHub Container Registry
54+
if: env.PUSH == 'true'
5255
uses: docker/login-action@v3
5356
with:
5457
registry: ghcr.io
@@ -81,7 +84,7 @@ jobs:
8184
with:
8285
context: docker/depends
8386
file: docker/depends/Dockerfile
84-
push: true
87+
push: ${{ env.PUSH }}
8588
platforms: linux/amd64
8689
cache-from: type=gha
8790
cache-to: type=gha,mode=max
@@ -116,7 +119,7 @@ jobs:
116119
with:
117120
context: .
118121
file: docker/base/Dockerfile
119-
push: true
122+
push: ${{ env.PUSH }}
120123
platforms: linux/amd64
121124
cache-from: type=gha
122125
cache-to: type=gha,mode=max
@@ -152,7 +155,7 @@ jobs:
152155
with:
153156
context: docker/models
154157
file: docker/models/Dockerfile
155-
push: true
158+
push: ${{ env.PUSH }}
156159
platforms: linux/amd64
157160
cache-from: type=gha
158161
cache-to: type=gha,mode=max
@@ -197,7 +200,7 @@ jobs:
197200
with:
198201
context: .
199202
file: docker/docs/Dockerfile
200-
push: true
203+
push: ${{ env.PUSH }}
201204
platforms: linux/amd64
202205
cache-from: type=gha
203206
cache-to: type=gha,mode=max
@@ -210,7 +213,7 @@ jobs:
210213
with:
211214
context: docker/executor
212215
file: docker/executor/Dockerfile
213-
push: true
216+
push: ${{ env.PUSH }}
214217
platforms: linux/amd64
215218
cache-from: type=gha
216219
cache-to: type=gha,mode=max
@@ -223,7 +226,7 @@ jobs:
223226
with:
224227
context: apps/api
225228
file: apps/api/Dockerfile
226-
push: true
229+
push: ${{ env.PUSH }}
227230
platforms: linux/amd64
228231
cache-from: type=gha
229232
cache-to: type=gha,mode=max
@@ -237,7 +240,7 @@ jobs:
237240
with:
238241
context: .
239242
file: docker/web/Dockerfile
240-
push: true
243+
push: ${{ env.PUSH }}
241244
platforms: linux/amd64,linux/arm64
242245
cache-from: type=gha
243246
cache-to: type=gha,mode=max
@@ -248,7 +251,7 @@ jobs:
248251
with:
249252
context: .
250253
file: shiny/dbsync/Dockerfile
251-
push: true
254+
push: ${{ env.PUSH }}
252255
platforms: linux/amd64
253256
cache-from: type=gha
254257
cache-to: type=gha,mode=max
@@ -261,7 +264,7 @@ jobs:
261264
with:
262265
context: docker/data
263266
file: docker/data/Dockerfile
264-
push: true
267+
push: ${{ env.PUSH }}
265268
platforms: linux/amd64,linux/arm64
266269
cache-from: type=gha
267270
cache-to: type=gha,mode=max
@@ -272,7 +275,7 @@ jobs:
272275
with:
273276
context: docker/monitor
274277
file: docker/monitor/Dockerfile
275-
push: true
278+
push: ${{ env.PUSH }}
276279
platforms: linux/amd64,linux/arm64
277280
cache-from: type=gha
278281
cache-to: type=gha,mode=max
@@ -283,7 +286,7 @@ jobs:
283286
with:
284287
context: docker/rstudio-nginx
285288
file: docker/rstudio-nginx/Dockerfile
286-
push: true
289+
push: ${{ env.PUSH }}
287290
platforms: linux/amd64,linux/arm64
288291
cache-from: type=gha
289292
cache-to: type=gha,mode=max
Lines changed: 95 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,101 @@
1-
name : Docker Stack Model Test
2-
on :
3-
# allow manual triggering
4-
workflow_dispatch:
5-
6-
schedule:
7-
# run Thursday 4:30 AM UTC
8-
- cron: '30 4 * * 4'
1+
name: Docker
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
pull_request:
8+
merge_group:
9+
910
jobs:
10-
sipnet:
11+
docker_build_and_stack_test:
1112
runs-on: ubuntu-latest
12-
1313
env:
14-
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
14+
R_VERSION: '4.2.2'
15+
DEFAULT_R_VERSION: '4.2.2'
16+
PUSH: ${{ github.event_name != 'pull_request' }}
1517

1618
steps:
17-
- name: Free Disk Space (Ubuntu)
18-
uses: jlumbroso/free-disk-space@main
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Login to DockerHub
23+
if: env.PUSH == 'true' && ${{ secrets.DOCKERHUB_USERNAME != '' }}
24+
uses: docker/login-action@v2
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_TOKEN }}
28+
29+
- name: Login to GitHub Container Registry
30+
if: env.PUSH == 'true'
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Build & push depends
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: ./depends
41+
push: ${{ env.PUSH }}
42+
43+
- name: Build & push base
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: ./base
47+
push: ${{ env.PUSH }}
48+
49+
- name: Build & push models
50+
uses: docker/build-push-action@v6
51+
with:
52+
context: ./models
53+
push: ${{ env.PUSH }}
54+
55+
- name: Build & push baseplus: docs
56+
uses: docker/build-push-action@v6
57+
with:
58+
context: ./baseplus/docs
59+
push: ${{ env.PUSH }}
60+
61+
- name: Build & push baseplus: executor
62+
uses: docker/build-push-action@v6
63+
with:
64+
context: ./baseplus/executor
65+
push: ${{ env.PUSH }}
66+
67+
- name: Build & push baseplus: api
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: ./baseplus/api
71+
push: ${{ env.PUSH }}
72+
73+
- name: Build & push extras: web
74+
uses: docker/build-push-action@v6
75+
with:
76+
context: ./extras/web
77+
push: ${{ env.PUSH }}
78+
79+
- name: Build & push extras: shiny-dbsync
80+
uses: docker/build-push-action@v6
81+
with:
82+
context: ./extras/shiny-dbsync
83+
push: ${{ env.PUSH }}
84+
85+
- name: Build & push extras: data
86+
uses: docker/build-push-action@v6
87+
with:
88+
context: ./extras/data
89+
push: ${{ env.PUSH }}
90+
91+
- name: Build & push extras: monitor
92+
uses: docker/build-push-action@v6
93+
with:
94+
context: ./extras/monitor
95+
push: ${{ env.PUSH }}
96+
97+
- name: Build & push extras: rstudio-nginx
98+
uses: docker/build-push-action@v6
1999
with:
20-
tool-cache: false
21-
android: true
22-
dotnet: true
23-
haskell: true
24-
large-packages: true
25-
docker-images: false
26-
swap-storage: true
27-
28-
- name: Checkout source code
29-
uses: actions/checkout@v4
30-
31-
- name: Set up Docker Compose
32-
run: |
33-
sudo apt-get update
34-
sudo apt-get -y install docker-compose
35-
36-
- name: Add Volumes to Executor
37-
run: |
38-
cp docker-compose.dev.yml docker-compose.override.yml
39-
sed -i'' '/R_library/d' docker-compose.override.yml
40-
41-
- name: Build Containers
42-
run: |
43-
cp docker/env.example .env
44-
echo "COMPOSE_PROJECT_NAME=pecan" >> .env
45-
echo "PECAN_VERSION=develop" >> .env
46-
echo "UID=$(id -u)" >> .env
47-
echo "GID=$(id -g)" >> .env
48-
49-
docker compose up --wait -d postgres
50-
docker run --rm --network pecan_pecan pecan/db:ci
51-
docker run --rm --network pecan_pecan --volume pecan_pecan:/data --env FQDN=docker pecan/data:develop
52-
docker run --rm --network pecan_pecan --volume pecan_pecan:/data pecan/data:develop chown -R "$(id -u):$(id -g)" /data
53-
docker image rm pecan/db:ci pecan/data:develop
54-
55-
- name: Run required containers
56-
run: |
57-
docker compose up --wait -d sipnet executor monitor rabbitmq
58-
59-
- name: List running containers
60-
run: |
61-
sleep 50
62-
docker ps
63-
64-
# - name: Add models
65-
# run: |
66-
# docker compose cp scripts/add.util.sh postgres:/tmp/add.util.sh
67-
# docker compose cp scripts/add.models.sh postgres:/tmp/add.models.sh
68-
# docker compose exec postgres /tmp/add.models.sh
69-
70-
- name: Run SIPNET
71-
run: |
72-
docker compose exec --workdir /pecan/tests executor R CMD ../web/workflow.R --settings docker-ghaction.sipnet.xml
100+
context: ./extras/rstudio-nginx
101+
push: ${{ env.PUSH }}

0 commit comments

Comments
 (0)