Update dev image #78
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: 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 |