Skip to content

v0.0.7

v0.0.7 #30

Workflow file for this run

name: Build and publish docker container
on:
schedule:
- cron: '30 15 * * *' # 每天 UTC 15:30(=北京 23:30)
release:
types: [published]
workflow_dispatch:
jobs:
publish:
name: Publish container image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
node-version: [24, 25]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check pushes today (UTC+8)
id: check_push
run: |
git fetch origin
TZ=Asia/Shanghai
since=$(date -d 'today 00:00' +"%Y-%m-%dT%H:%M:%S")
if git log --since="$since" --format=oneline origin/main origin/refactor | head -n 1; then
echo "has_push=true" >> "$GITHUB_OUTPUT"
else
echo "has_push=false" >> "$GITHUB_OUTPUT"
fi
- name: OCI meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest=${{ matrix.node-version == 25 && 'true' || 'false' }}
suffix=${{ matrix.node-version == 24 && '-node-24' || '' }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
if: github.event_name != 'schedule' || steps.check_push.outputs.has_push == 'true'
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
REPO=${{ github.repository }}
REF=${{ github.ref }}
COMMIT=${{ github.sha }}
USE_MIRROR=false
NODE_VERSION=${{ matrix.node-version }}-slim
secrets: |
npmrc=//npm.pkg.github.com/:_authToken=${{ secrets.GPR_TOKEN }}
- name: Send Telegram Notification on Failure
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO_GROUP }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
❌ Docker Build Failed
Repo: ${{ github.repository }}
Ref: ${{ github.ref_name }}
Commit: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
Check details: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Send Telegram Notification on Success
if: success() && (github.event_name != 'schedule' || steps.check_push.outputs.has_push == 'true') && matrix.node-version == 25
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO_GROUP }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
✅ Docker Build Success
Repo: ${{ github.repository }}
Tag/Branch: ${{ github.ref_name }}
Image: ghcr.io/${{ github.repository }}:${{ github.ref_name }}