Skip to content

Patch: Address Failing Check and Add Config.env Check #11

Patch: Address Failing Check and Add Config.env Check

Patch: Address Failing Check and Add Config.env Check #11

Workflow file for this run

name: Validate Images
on:
pull_request:
branches: [ main ]
permissions: read-all
jobs:
build:
name: Validate Updated Images
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf #v45.0.4
with:
dir_names: 'true'
- name: Build Changed Images
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
BASE_DIR=$(pwd)
for dir in ${ALL_CHANGED_FILES}; do
echo "Change detected in $dir ..."
cd $dir
if [ ! -f config.env ] && ([ -f Dockerfile ] || [ -f Containerfile ]); then
echo "No config.env file present in changed directory that contains image files. Throwing error ..."
exit 1
elif [ ! -f config.env ]; then
echo "No config.env file present in changed directory, skipping ..."
cd $BASE_DIR
continue
fi
echo "Running 'docker build' in $dir ..."
if [ -f "Containerfile" ]; then
docker build -f Containerfile .
else
docker build -f Dockerfile .
fi
cd $BASE_DIR
done