-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to rebuild master on cron
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |