Skip to content

Commit

Permalink
Add workflow to rebuild master on cron
Browse files Browse the repository at this point in the history
  • Loading branch information
macropin committed Oct 28, 2021
1 parent 37d0569 commit ab7daa4
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-images-cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---

name: Build Images Cron

# Rebuild images from master branch every Sunday

on:
schedule:
- cron: "0 0 * * 0"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: master

- name: Get build tag
id: get_build_tag
# You must push tags first before pushing refs, otherwise you'll never build an image
# tagged with a git tag.
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//g')"
else
TAG="$(echo ${GITHUB_REF#refs/heads/} | tr '/-' '_')-${GITHUB_SHA:0:7}-$(date -u +'%Y%m%d%H%M')"
fi
echo "TAG: ${TAG}"
echo "::set-output name=tag::${TAG}"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.PANUBUILD_DOCKERHUB_USERNAME }}
password: ${{ secrets.PANUBUILD_DOCKERHUB_TOKEN }}

- name: Build and Push
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: Dockerfile
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
tags: |
panubo/sshd:latest
panubo/sshd:${{ steps.get_build_tag.outputs.tag }}

0 comments on commit ab7daa4

Please sign in to comment.