Merge branch 'develop' of https://github.com/CUAHSI/cuahsi-model-imag… #50
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: Build and Publish to Registry on Github push | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
IMAGE_ROOT: singleuser | |
REGISTRY_HOSTNAME: docker.io | |
DOCKER_USER: ${{ secrets.DOCKER_USER }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }} | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
on: | |
push: | |
paths: | |
- "singleuser/**" | |
jobs: | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
# Expose matched filters as job 'variants' output variable | |
image_variants: ${{ steps.filter.outputs.changes }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dorny/paths-filter@v2 | |
# https://github.com/marketplace/actions/paths-changes-filter#conditional-execution | |
id: filter | |
with: | |
filters: | | |
base: ${{ env.IMAGE_ROOT }}/base/** | |
scientific-py3: ${{ env.IMAGE_ROOT }}/python3-scientific/** | |
scientific-r: ${{ env.IMAGE_ROOT }}/r/** | |
summa-py3: ${{ env.IMAGE_ROOT }}/python3-summa/** | |
wrfhydro: ${{ env.IMAGE_ROOT }}/python3-wrfhydro/** | |
csdms-tools: ${{ env.IMAGE_ROOT }}/csdms-tools/** | |
setup-build-publish-deploy: | |
needs: detect-changes | |
name: Setup, Build, and Publish | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
max-parallel: 6 | |
matrix: | |
IMAGE_VARIANT: ${{ fromJSON(needs.detect-changes.outputs.image_variants) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Load .env file | |
uses: xom9ikk/dotenv@v2 | |
with: | |
path: ${{ env.IMAGE_ROOT }} | |
- name: Docker Login | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin | |
# Build the Docker image | |
- name: Build | |
run: | | |
cd "${IMAGE_ROOT}" | |
docker compose build ${{ matrix.IMAGE_VARIANT }} | |
- name: Echo env configuration and set image tag | |
id: tagging | |
run: | | |
echo "IMAGE_VARIANT: ${{ matrix.IMAGE_VARIANT }}" | |
echo "JH_BASE: ${{ env.JH_BASE }}" | |
echo "CUAHSI_BASE: ${{ env.CUAHSI_BASE }}" | |
echo "BUILD_DATE: ${{ env.BUILD_DATE }}" | |
echo "GITHUB_SHA: $GITHUB_SHA" | |
echo "BRANCH_NAME: $BRANCH_NAME" | |
echo ------------ | |
export DOCKER_TAG="${REPOSITORY}/${IMAGE_ROOT}-${{ matrix.IMAGE_VARIANT }}:${{ env.CUAHSI_BASE }}" | |
export DOCKER_FULL_PATH="${REPOSITORY}/${IMAGE_ROOT}:$BRANCH_NAME-latest" | |
echo "DOCKER_FULL_PATH=$DOCKER_FULL_PATH" >> $GITHUB_ENV | |
echo $DOCKER_FULL_PATH | |
docker tag $DOCKER_TAG $DOCKER_FULL_PATH | |
- name: Push Docker Image | |
run: | | |
docker push ${{ env.DOCKER_FULL_PATH }} | |
# TODO: run tests? |