Skip to content

Instantly share code, notes, and snippets.

@atton
Last active June 9, 2020 02:37
Show Gist options
  • Save atton/ca0a242f60fd4e65bb0b315454e73e93 to your computer and use it in GitHub Desktop.
Save atton/ca0a242f60fd4e65bb0b315454e73e93 to your computer and use it in GitHub Desktop.
# Original: https://github.com/atton/dockerfiles/blob/1566be5489c34ba743dd5735f6584d3ef213cdb5/.github/workflows/build-and-push.yml
name: Build and Push Docker Images
on: push
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Clone repository
run: git clone https://github.com/atton/dockerfiles
- name: Build and Push Docker Images
run: sh dockerfiles/build.sh ${{ secrets.DOCKER_PASSWORD }}
# Original: https://github.com/atton/dockerfiles/blob/1566be5489c34ba743dd5735f6584d3ef213cdb5/build.sh
#!/bin/sh
cd `dirname $0`
git show --name-only
if [ -n "$1" ]; then docker login -u atton -p $1; fi
for name in `ls`; do
if [ ! -d $name ]; then continue; fi
if [ ! -f $name/Dockerfile ]; then continue; fi
tag="atton/$name"
docker build --compress --pull -t $tag $name
git diff-tree --no-commit-id --name-only -r master | grep "$name/" >/dev/null 2>&1
if [ $? -eq 0 ]; then docker push $tag; fi
done
if [ -n "$1" ]; then docker logout; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment