ci: manglet content, gjort jobber mer like #259
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: Jupyter | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- .github/workflows/jupyter.yaml | |
- jupyter/Dockerfile | |
- compare_tags.py | |
workflow_dispatch: | |
schedule: | |
- cron: "0 8 * * *" | |
env: | |
IMAGE: jupyter | |
permissions: | |
contents: read | |
id-token: write | |
packages: write | |
jobs: | |
build: | |
name: Python | |
strategy: | |
matrix: | |
version: ["3.8", "3.9", "3.10", "3.11"] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Check if we can build Dockerfile | |
uses: docker/build-push-action@v4 | |
with: | |
file: jupyter/Dockerfile | |
load: true | |
build-args: python_version=${{ matrix.version }} | |
- id: auth | |
name: Authenticate with Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
token_format: access_token | |
workload_identity_provider: projects/193123067890/locations/global/workloadIdentityPools/ci-knada-images/providers/ci-knada-images | |
service_account: [email protected] | |
- name: Install dependency for compare_tags.py script | |
run: pip install -r .github/scripts/requirements.txt | |
- name: Check if jupyter/base-image has updated | |
run: | | |
knada=$(gcloud artifacts docker images list europe-north1-docker.pkg.dev/knada-gcp/knada-north/jupyter --include-tags --filter TAGS:-${{ matrix.version }} --sort-by=~Update_Time --limit=1 --format=json) | |
python3 .github/scripts/compare_tags.py jupyterhub "$knada" "python-${{ matrix.version }}" || out=$? | |
if [ $out -eq 100 ] | |
then | |
echo "OUTDATED=true" >> $GITHUB_ENV | |
exit 0 | |
fi | |
- uses: docker/login-action@v2 | |
name: Login to Google Artifact Registry | |
with: | |
registry: europe-north1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- uses: docker/login-action@v2 | |
name: Login to GitHub Container Registry | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: echo "TAG=$(git log -1 --pretty=%ad --date=format:%Y-%m-%d)-$(git log --pretty=format:'%h' -n 1)" >> $GITHUB_ENV | |
- uses: docker/build-push-action@v4 | |
if: env.OUTDATED == 'true' || contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) | |
with: | |
file: jupyter/Dockerfile | |
push: true | |
build-args: python_version=${{ matrix.version }} | |
tags: | | |
europe-north1-docker.pkg.dev/knada-gcp/knada-north/${{ env.IMAGE }}:${{ env.TAG }}-${{ matrix.version }} | |
ghcr.io/${{ github.repository }}/${{ env.IMAGE }}:${{ env.TAG }}-${{ matrix.version }} |