Skip to content

Merge pull request #98 from nmfs-opensci/eeholmes-patch-4 #27

Merge pull request #98 from nmfs-opensci/eeholmes-patch-4

Merge pull request #98 from nmfs-opensci/eeholmes-patch-4 #27

name: Docker Image Build and Push Geospatial
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'action.yml'
- '.github/workflows/build-and-push-geospatial.yml'
- 'images/py-rocket-geospatial-qgis/**'
- 'images/py-rocket-geospatial/**'
- 'images/py-geospatial/**'
env:
WATCHED_DIRECTORIES: |
images/py-geospatial
images/py-rocket-geospatial
images/py-rocket-geospatial-qgis
jobs:
find-changes:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.find-changes.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Find changed directories
id: find-changes
run: |
watched_dirs=$(echo "${WATCHED_DIRECTORIES}" | tr '\n' '|')
echo "DEBUG: watched_dirs=${watched_dirs}"
all_changed_dirs=$(git diff --name-only HEAD^ HEAD | grep -E "^(${watched_dirs})" || true)
echo "DEBUG: all_changed_dirs=$all_changed_dirs"
dirs=$(echo "$all_changed_dirs" | while read -r path; do
for watched in ${WATCHED_DIRECTORIES}; do
if [[ "$path" == "$watched" || "$path" == "$watched/"* ]]; then
echo "$watched"
fi
done
done | sort -u)
echo "DEBUG: filtered dirs=$dirs"
if [ -z "$dirs" ]; then
echo "No changes detected."
matrix_dirs="[]"
else
matrix_dirs=$(echo "$dirs" | jq -R -s -c 'split("\n") | map(select(. != ""))')
fi
echo "::set-output name=changed::$matrix_dirs"
echo "DEBUG: final matrix_dirs=$matrix_dirs"
build-py-geospatial:
runs-on: ubuntu-latest
needs: find-changes
steps:
- uses: actions/checkout@v3
- name: Decide if build needed
id: decide
run: |
if echo '${{ needs.find-changes.outputs.changed }}' | jq -e '. | index("images/py-geospatial")' > /dev/null; then
echo "BUILD_NEEDED=true" >> $GITHUB_ENV
else
echo "BUILD_NEEDED=false" >> $GITHUB_ENV
fi
- name: Build py-geospatial
if: env.BUILD_NEEDED == 'true'
uses: nmfs-opensci/container-images@main
with:
image_dir: images/py-geospatial
image_name: container-images/py-geospatial
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: No build needed for py-geospatial
if: env.BUILD_NEEDED == 'false'
run: echo "No changes for py-geospatial; nothing to build."
build-py-rocket-geospatial:
runs-on: ubuntu-latest
needs: [find-changes, build-py-geospatial]
steps:
- uses: actions/checkout@v3
- name: Decide if build needed
id: decide
run: |
if echo '${{ needs.find-changes.outputs.changed }}' | jq -e '. | index("images/py-rocket-geospatial")' > /dev/null; then
echo "BUILD_NEEDED=true" >> $GITHUB_ENV
else
echo "BUILD_NEEDED=false" >> $GITHUB_ENV
fi
- name: Build py-rocket-geospatial
if: env.BUILD_NEEDED == 'true'
uses: nmfs-opensci/container-images@main
with:
image_dir: images/py-rocket-geospatial
image_name: container-images/py-rocket-geospatial
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: No build needed for py-rocket-geospatial
if: env.BUILD_NEEDED == 'false'
run: echo "No changes for py-rocket-geospatial; nothing to build."
build-py-rocket-geospatial-qgis:
runs-on: ubuntu-latest
needs: [find-changes, build-py-rocket-geospatial]
steps:
- uses: actions/checkout@v3
- name: Decide if build needed
id: decide
run: |
if echo '${{ needs.find-changes.outputs.changed }}' | jq -e '. | index("images/py-rocket-geospatial-qgis")' > /dev/null; then
echo "BUILD_NEEDED=true" >> $GITHUB_ENV
else
echo "BUILD_NEEDED=false" >> $GITHUB_ENV
fi
- name: Build py-rocket-geospatial-qgis
if: env.BUILD_NEEDED == 'true'
uses: nmfs-opensci/container-images@main
with:
image_dir: images/py-rocket-geospatial-qgis
image_name: container-images/py-rocket-geospatial-qgis
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: No build needed for py-rocket-geospatial-qgis
if: env.BUILD_NEEDED == 'false'
run: echo "No changes for py-rocket-geospatial-qgis; nothing to build."