Skip to content

Auto Nightly Image #121

Auto Nightly Image

Auto Nightly Image #121

name: Auto Nightly Image
permissions: write-all
on:
schedule:
# each day
- cron: "0 0 * * *"
workflow_call:
inputs:
ref:
required: true
type: string
push:
required: true
type: string
workflow_dispatch:
inputs:
ref:
description: "branch, tag"
required: true
type: string
push:
description: "push image or not"
required: true
type: string
env:
BUILD_PLATFORM: linux/amd64,linux/arm64
ONLINE_REGISTER: ghcr.io
ONLINE_REGISTER_USER: ${{ github.actor }}
ONLINE_REGISTER_PASSWORD: ${{ secrets.PUSH_TOKEN }}
jobs:
build-and-push:
if: github.repository == 'kcrow-io/kcrow'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: daemon
dockerfile: ./images/daemon/Dockerfile
context: ./
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Login to online register
uses: docker/[email protected]
with:
username: ${{ env.ONLINE_REGISTER_USER }}
password: ${{ env.ONLINE_REGISTER_PASSWORD }}
registry: ${{ env.ONLINE_REGISTER }}
- name: Getting image tag
id: tag
run: |
echo ${{ github.event_name }}
if ${{ inputs.ref != '' }}; then
echo "trigger by workflow_call"
echo "tag=${{ inputs.ref }}" >> $GITHUB_ENV
echo "push=${{ inputs.push }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "trigger by workflow_dispatch"
echo "tag=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
echo "push=${{ github.event.inputs.push }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'schedule' }} ; then
echo "trigger by cron schedule"
echo "tag=main" >> $GITHUB_ENV
echo "push=true" >> $GITHUB_ENV
else
echo "trigger by ${{ github.event_name }}"
echo "tag=${{ github.sha }}" >> $GITHUB_ENV
echo "push=false" >> $GITHUB_ENV
fi
- name: Checkout Source Code
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ env.tag }}
- name: Build Image ${{ matrix.name }}
uses: docker/[email protected]
id: docker_build_release
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: ${{ env.push }}
provenance: false
platforms: ${{ env.BUILD_PLATFORM }}
tags: |
${{ env.ONLINE_REGISTER }}/${{ github.repository }}/${{ matrix.name }}:${{ env.tag }}
build-args: |
GIT_COMMIT_VERSION=${{ env.commitver }}
GIT_COMMIT_TIME=${{ env.committime }}
VERSION=${{ env.ref }}