Build Docker Image #1426
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: Build Docker Image | |
on: | |
schedule: | |
- cron: '0 4,16 * * *' | |
workflow_dispatch: | |
inputs: | |
forceBuild: | |
description: 'Force build manually' | |
required: true | |
default: 'yes' | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.release.outputs.tag }} | |
days: ${{ steps.release.outputs.days }} | |
steps: | |
- name: Get release info | |
id: release | |
run: | | |
tag=$(curl -s https://api.github.com/repos/marcantondahmen/automad/releases/latest | jq -r ".tag_name") | |
days=$(curl -s https://api.github.com/repos/marcantondahmen/automad/releases/latest | jq -r "((now - (.published_at | fromdateiso8601)) / (60 * 60 * 24) | trunc)") | |
echo "$days days since the latest release with tag $tag was published" | |
echo "::set-output name=tag::$tag" | |
echo "::set-output name=days::$days" | |
build: | |
runs-on: ubuntu-latest | |
needs: check | |
if: ${{ needs.check.outputs.days == '0' || github.event.inputs.forceBuild == 'yes' }} | |
steps: | |
- name: Release Info | |
run: | | |
echo "Days since latest release was published: ${{ needs.check.outputs.days }}" | |
echo "Latest release tag: ${{ needs.check.outputs.tag }}" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: | | |
automad/automad:latest | |
automad/automad:${{ needs.check.outputs.tag }} |