ci(gh-actions): add scheduler for running every monday at 00:00 (th t⦠#18
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: π³ Docker Workflow | |
on: | |
push: | |
branches: | |
- main | |
- docker | |
pull_request: | |
branches: | |
- docker | |
workflow_dispatch: | |
inputs: | |
image_tag: | |
description: 'Docker image tag to use (default: latest)' | |
required: false | |
default: 'latest' | |
build_context: | |
description: 'Build context directory (default: .)' | |
required: false | |
default: '.' | |
schedule: | |
- cron: '0 17 * * 1' # Every Monday at 00:00 GMT+7 | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: pungrumpy/dotfiles | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
attestations: write | |
jobs: | |
build-and-push: | |
name: π Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: ποΈ Checkout Repository | |
uses: actions/checkout@v4 | |
- name: π Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: πͺ Extract Metadata for Docker | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: ${{ github.event.inputs.image_tag || 'latest' }} | |
- name: ποΈ Build and Push Docker Image | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ github.event.inputs.build_context || '.' }} | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
- name: π¦ Generate Artifact Attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
subject-digest: ${{ steps.build.outputs.digest }} | |
push-to-registry: true |