Skip to content

update: v5.18.3,v5.17.6,v5.16.7 added #16

update: v5.18.3,v5.17.6,v5.16.7 added

update: v5.18.3,v5.17.6,v5.16.7 added #16

name: Build and Push Docker Images
on:
push:
branches:
- main
env:
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to Docker Hub
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- name: Determine changed Dockerfiles
id: find-dockerfiles
run: |
changed_files=$(git diff --name-only HEAD~1 || git ls-files --exclude='*')
dockerfiles=$(find . -name "Dockerfile" -printf '%P\n')
changed_dockerfiles=""
for file in $dockerfiles; do
if [[ $changed_files == *"$file"* ]]; then
changed_dockerfiles+=" $file"
fi
done
echo "::set-output name=changed_dockerfiles::$changed_dockerfiles"
- name: Build and push Docker images
run: |
for dockerfile in ${{ steps.find-dockerfiles.outputs.changed_dockerfiles }}; do
folder=$(dirname $dockerfile)
docker build -t dinifarb/activemq:"$folder" "$folder"
docker push dinifarb/activemq:"$folder"
done