Removes textlive-full to reduce container size #117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" | ||
if: github.event_name == "pull_request" | ||
Check failure on line 28 in .github/workflows/containers.yaml
|
||
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.listPullRequestsAssociatedWithCommit({ | ||
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-earth-science-notebook: | ||
needs: | ||
- get-issue-number | ||
- build-minimal-notebook | ||
runs-on: ubuntu-latest | ||
name: Build earth-science-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 | ||
VERSION=pr-${{ needs.get-issue-number.outputs.pr-number }} | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
echo "build-args=TAG=$VERSION" >> $GITHUB_OUTPUT | ||
else | ||
pip install tbump | ||
pushd dockerfiles/earth-science-notebook | ||
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT | ||
echo "build-args=" >> $GITHUB_OUTPUT | ||
fi | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: dockerfiles/earth-science-notebook | ||
push: true | ||
tags: ghcr.io/esgf-nimbus/earth-science-notebook:${{ steps.get-version.outputs.version }} | ||
build-args: "${{ steps.get-version.outputs.build-args }}" | ||
build-earth-science-notebook-gpu: | ||
needs: | ||
- get-issue-number | ||
- build-earth-science-notebook | ||
runs-on: ubuntu-latest | ||
name: Build earth-science-notebook-gpu | ||
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 | ||
VERSION=pr-${{ needs.get-issue-number.outputs.pr-number }} | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
echo "build-args=TAG=$VERSION" >> $GITHUB_OUTPUT | ||
else | ||
pip install tbump | ||
pushd dockerfiles/earth-science-notebook-gpu | ||
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT | ||
echo "build-args=" >> $GITHUB_OUTPUT | ||
fi | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: dockerfiles/earth-science-notebook-gpu | ||
push: true | ||
tags: ghcr.io/esgf-nimbus/earth-science-notebook-gpu:${{ steps.get-version.outputs.version }} | ||
build-args: "${{ steps.get-version.outputs.build-args }}" | ||
other-containers: | ||
runs-on: ubuntu-latest | ||
name: Get other containers | ||
outputs: | ||
directories: "${{ steps.get-paths.outputs.directories }}" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: get-paths | ||
run: | | ||
CONTAINERS="$(ls dockerfiles/ | grep -v -E "Makefile|earth-science*|minimal" | jq -R -s -c 'split("\n")[:-1]')" | ||
echo "directories=$CONTAINERS" >> $GITHUB_OUTPUT | ||
build-other-containers: | ||
needs: | ||
- get-issue-number | ||
- other-containers | ||
runs-on: ubuntu-latest | ||
name: Build other containers | ||
permissions: | ||
packages: write | ||
strategy: | ||
matrix: | ||
directory: ${{ fromJSON(needs.other-containers.outputs.directories) }} | ||
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 | ||
VERSION=pr-${{ needs.get-issue-number.outputs.pr-number }} | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
else | ||
pip install tbump | ||
pushd dockerfiles/${{ matrix.directory }} | ||
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/${{ matrix.directory }} | ||
push: true | ||
tags: ghcr.io/esgf-nimbus/${{ matrix.directory }}:${{ steps.get-version.outputs.version }} |