-
-
Notifications
You must be signed in to change notification settings - Fork 30
73 lines (64 loc) · 2.74 KB
/
update-dockerfile-dev.yml
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
name: Update dev image
on:
schedule:
- cron: '0 1 * * *' # Run every day
workflow_dispatch:
env:
SAGE_TARGET: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-targets
SAGE_SYSTEM: ghcr.io/sagemath/sage/sage-ubuntu-focal-standard-with-system-packages
TAG: dev
BRANCH: dev
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
# Prepare .github/Dockerfile for slim Sage image
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
- name: Get SageMath version
run: |
SAGE_VERSION=$(docker run --rm ${SAGE_TARGET}:$TAG /sage/sage --version | grep -oP 'SageMath version \K[0-9.]+(?:beta\d+)?(?:rc\d+)?')
echo "SAGE_VERSION=${SAGE_VERSION}" >> $GITHUB_ENV
- name: Update version in files
run: |
SAGE_TARGET_ESCAPED=$(echo "${SAGE_TARGET}" | sed 's/\//\\\//g' | sed 's/\./\\\./g')
SAGE_TARGET_VERSION_ESCAPED=$(echo "${SAGE_TARGET}:${SAGE_VERSION}" | sed 's/\//\\\//g' | sed 's/\./\\\./g')
sed -i "s/FROM ${SAGE_TARGET_ESCAPED}:\S*/FROM ${SAGE_TARGET_VERSION_ESCAPED}/g" .github/Dockerfile
SAGE_SYSTEM_ESCAPED=$(echo "${SAGE_SYSTEM}" | sed 's/\//\\\//g' | sed 's/\./\\\./g')
SAGE_SYSTEM_VERSION_ESCAPED=$(echo "${SAGE_SYSTEM}:${SAGE_VERSION}" | sed 's/\//\\\//g' | sed 's/\./\\\./g')
sed -i "s/FROM ${SAGE_SYSTEM_ESCAPED}:\S*/FROM ${SAGE_SYSTEM_VERSION_ESCAPED}/g" .github/Dockerfile
PACKAGE_NAME=ghcr.io/${{ github.repository }}:${SAGE_VERSION}
PACKAGE_NAME_ESCAPED=$(echo "${PACKAGE_NAME}" | sed 's/\//\\\//g')
sed -i "s/FROM \S*/FROM ${PACKAGE_NAME_ESCAPED}/g" Dockerfile
sed -i "s/FROM \S*/FROM ${SAGE_TARGET_VERSION_ESCAPED}/g" README.rst
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
- name: Commit changes
run: |
git config --global user.email alice@wonderland
git config --global user.name alice
git commit -a --amend -m "Dockerfile for Sage ${SAGE_VERSION}"
git push -f origin $BRANCH
# Build and publish the slim Sage image to github package registry (ghpr)
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .github
push: true
tags: ${{ env.PACKAGE_NAME }}
# Build docker image for Binder from Dockerfile at root
- name: Binder build
timeout-minutes: 30
continue-on-error: true
run: |
curl --keepalive-time 600 -L https://mybinder.org/build/gh/sagemath/sage-binder-env/$BRANCH