-
Notifications
You must be signed in to change notification settings - Fork 2
111 lines (105 loc) · 3.26 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
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:
get-issue-number:
runs-on: ubuntu-latest
name: Get PR number
permissions:
contents: read
outputs:
pr-number: "${{ steps.pr-number.outputs.pr-number }}"
steps:
- uses: actions/github-script@v6
id: get-issue-number
with:
script: |
if (context.issue.number) {
return context.issue.number;
} else {
return (
await github.rest.repos.listPullRequestAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
}).data[0].number;
}
result-encoding: string
- id: pr-number
run: echo "pr-number=${{ steps.get-issue-number.outputs.result }}" >> $GITHUB_OUTPUT
build-minimal-notebook:
needs:
- get-issue-number
runs-on: ubuntu-latest
name: Build minimal-notebook
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- id: get-version
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "version=pr-${{ needs.get-issue-number.outputs.pr-number }}" >> $GITHUB_OUTPUT
else
pip install tbump
pushd dockerfiles/minimal-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
fi
- uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/minimal-notebook
push: true
tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }}
# build-climate-notebook:
# needs:
# - build-minimal-notebook
# runs-on: ubuntu-latest
# name: Build climate-notebook
# permissions:
# packages: write
# steps:
# - uses: actions/checkout@v4
# - uses: docker/setup-buildx-action@v3
# - uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - uses: actions/setup-python@v5
# 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@v5
# with:
# cache-from: type=gha
# cache-to: type=gha,mode=max
# context: dockerfiles/climate-notebook
# push: ${{ github.event_name == 'push' }}
# tags: ghcr.io/esgf-nimbus/climate-notebook:${{ steps.get-version.outputs.version }}