Update base Python container images #126
This file contains hidden or 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 base Python container images" | |
| on: | |
| schedule: | |
| - cron: '0 0 * * MON' | |
| workflow_dispatch: | |
| jobs: | |
| pythons: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| versions: ${{ steps.set-pythons.outputs.pythons }} | |
| steps: | |
| - id: set-pythons | |
| run: | | |
| ## script to get current Python versions from the source of truth | |
| data=`curl -s --url "https://peps.python.org/api/release-cycle.json"` | |
| pythonarray=`echo ${data} | jq '.[] | select((.status!="end-of-life") and (.status!="prerelease")) | select(.branch | startswith("3.")) | .branch' | jq -s -c` | |
| echo "pythons=${pythonarray}" >> "$GITHUB_OUTPUT" | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: pythons | |
| strategy: | |
| matrix: | |
| py_version: ${{ fromJson(needs.pythons.outputs.versions) }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Auth to Cloud | |
| uses: 'uwit-iam/action-auth-artifact-registry@main' | |
| with: | |
| credentials: "${{ secrets.MCI_GCLOUD_AUTH_JSON }}" | |
| enable_private_docker: true | |
| - name: Record timestamp for image | |
| id: timestamp | |
| run: | | |
| echo "value=$(date +%Y.%m.%d.%H.%M.%S)" >> $GITHUB_OUTPUT # e.g., 2024.01.17.15.09.31 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push to GAR | |
| env: | |
| image_uri: "us-docker.pkg.dev/uwit-mci-iam/containers/base-python-${{ matrix.py_version }}" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: "{{defaultContext}}:images/python-base" | |
| platforms: linux/amd64,linux/arm64 | |
| build-args: | | |
| PYTHON_VERSION=${{ matrix.py_version }} | |
| TIMESTAMP=${{ steps.timestamp.outputs.value }} | |
| push: true | |
| tags: | | |
| ${{ env.image_uri }}:latest | |
| ${{ env.image_uri }}:${{ steps.timestamp.outputs.value }} |