Daily tagging #1592
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: Daily tagging | |
on: | |
repository_dispatch: | |
types: release | |
schedule: | |
- cron: "59 23 * * *" | |
jobs: | |
release: | |
env: | |
IMAGE_BASENAME: colomoto/colomoto-docker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: master | |
token: ${{ secrets.PAT }} | |
- name: Tags | |
run: | | |
set -ex | |
git fetch --depth=1 origin +refs/tags/*:refs/tags/* | |
echo LATEST_TAG=$(git tag|grep -v mybinder|sort|tail -n1) >> $GITHUB_ENV | |
echo NEXT_TAG=$(git log -1 --format=%cs) >> $GITHUB_ENV | |
shell: bash | |
- name: Check for changes | |
run: | | |
set -x | |
[[ "$(git rev-parse HEAD)" == "$(git rev-parse $LATEST_TAG)" ]] && exit 0 | |
git diff --quiet $LATEST_TAG.. Dockerfile && exit 0 | |
echo HAS_CHANGES=1 >> $GITHUB_ENV | |
echo IMAGE=${IMAGE_BASENAME}:${NEXT_TAG} >> $GITHUB_ENV | |
shell: bash | |
- name: Docker image build | |
if: env.HAS_CHANGES == 1 | |
run: sh hooks/build | |
- name: Docker image validation | |
if: env.HAS_CHANGES == 1 | |
run: docker run --rm $IMAGE env validate.sh | |
- name: Login to docker hub | |
if: env.HAS_CHANGES == 1 | |
uses: actions-hub/docker/login@master | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push image release | |
if: env.HAS_CHANGES == 1 | |
uses: actions-hub/docker@master | |
with: | |
args: push ${IMAGE} | |
- name: Git tag | |
if: env.HAS_CHANGES == 1 | |
run: | | |
git tag $NEXT_TAG | |
git push --tags |