-
Notifications
You must be signed in to change notification settings - Fork 2
146 lines (139 loc) · 4.59 KB
/
containers.yaml
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
name: Containers
on:
push:
branches:
- main
paths:
- 'dockerfiles/**'
pull_request:
branches:
- main
paths:
- 'dockerfiles/**'
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
detect-changes:
runs-on: ubuntu-latest
name: Detect changes to Dockerfiles
permissions:
pull-requests: read
outputs:
modified_files_count: ${{ steps.changed-files.outputs.modified_files_count }}
other_modified_files_count: ${{ steps.changed-files.outputs.other_modified_files_count }}
directories: ${{ steps.format.outputs.directories }}
steps:
- uses: actions/checkout@v3
- name: Detect changed files
id: changed-files
uses: tj-actions/changed-files@v37
with:
path: dockerfiles
dir_names: true
dir_names_max_depth: 1
dir_names_exclude_current_dir: true
files: minimal-notebook/**
- id: format
run: |
echo "${{ steps.changed-files.outputs.other_modified_files }}" | python -c "import sys,json;d=json.dumps({'directories': sys.stdin.read().strip().split(' ')});print(f'directories={d}')" >> $GITHUB_OUTPUT
build-minimal-notebook:
if: needs.detect-changes.outputs.modified_files_count > 0
needs:
- detect-changes
runs-on: ubuntu-latest
name: Build minimal-notebook
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: get-version
run: |
pip install tbump
pushd dockerfiles/minimal-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/minimal-notebook
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }}
build-climate-notebook:
if: needs.detect-changes.outputs.modified_files_count > 0
needs:
- detect-changes
- build-minimal-notebook
runs-on: ubuntu-latest
name: Build climate-notebook
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: get-version
run: |
pip install tbump
pushd dockerfiles/climate-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/minimal-notebook
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/esgf-nimbus/climate-notebook:${{ steps.get-version.outputs.version }}
build-other-containers:
if: always() && needs.detect-changes.outputs.other_modified_files_count > 0
needs:
- detect-changes
- build-climate-notebook
runs-on: ubuntu-latest
name: Build other containers
permissions:
packages: write
strategy:
matrix: ${{ fromJSON(needs.detect-changes.outputs.directories) }}
exclude:
- directories: minimal-notebook
- directories: climate-notebook
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: get-version
run: |
pip install tbump
pushd dockerfiles/${{ matrix.directories }}
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/${{ matrix.directories }}
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/esgf-nimbus/${{ matrix.directories }}:${{ steps.get-version.outputs.version }}