Skip to content

Merge pull request #40 from uw-it-aca/pm-add_build_automation #3

Merge pull request #40 from uw-it-aca/pm-add_build_automation

Merge pull request #40 from uw-it-aca/pm-add_build_automation #3

name: rttl-notebook-images-ci
on:
push:
branches:
- 'main'
env:
GAR_LOCATION: us-west1
jobs:
get-changed:
# check for any changes to a worker VERSION file
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.mapped-files.outputs.matrix }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
**/VERSION
json: true
write_output_files: true
-
name: Map to JSON
# Get the parent folder and add to an array
id: mapped-files
run: |
set -eux
DATA=$(echo ${{ steps.changed-files.outputs.all_changed_files }} | jq -c '. | map(split("/")[0]) | unique')
echo "matrix=$DATA" >> "$GITHUB_OUTPUT"
build-workers:
needs: get-changed
# Skip if no changes in worker versions in this push
if: needs.get-changed.outputs.matrix != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
versions: ${{ fromJSON(needs.get-changed.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Get version number
# Read the version number out of worker_name/VERSION and push to ENV
env:
CTX: ${{ matrix.versions }}
run: |
VER=$(cat ${CTX}/VERSION)
echo "VERSION=$VER" >> $GITHUB_ENV
-
name: Docker login with GCP credentials
id: gcp-login
shell: bash
run: |
echo "${{ secrets.GCP_JSON_KEY }}" |
base64 -d |
docker login --username=_json_key --password-stdin https://${{ env.GAR_LOCATION }}-docker.pkg.dev
-
name: Build and push
# Build docker image using the app folder context.
# Tag with worker name and version string
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:${{ matrix.versions }}"
push: true
tags: |
${{ env.GAR_LOCATION }}-docker.pkg.dev/uwit-mci-axdd/rttl-images/jupyter-${{ matrix.versions }}-notebook:${{ env.VERSION }}
${{ env.GAR_LOCATION }}-docker.pkg.dev/uwit-mci-axdd/rttl-images/jupyter-${{ matrix.versions }}-notebook:latest