From ab7daa43ea301cf041dd8a4fa7b744aa34391e61 Mon Sep 17 00:00:00 2001 From: Andrew Cutler Date: Thu, 28 Oct 2021 16:09:36 +1100 Subject: [PATCH] Add workflow to rebuild master on cron --- .github/workflows/build-images-cron.yml | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build-images-cron.yml diff --git a/.github/workflows/build-images-cron.yml b/.github/workflows/build-images-cron.yml new file mode 100644 index 0000000..66bfa70 --- /dev/null +++ b/.github/workflows/build-images-cron.yml @@ -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 }}