feat: standardize logs and support node 25 build matrix #13
This file contains hidden or 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: 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 | ||
| 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 == 24 && 'true' || 'false' }} | ||
| suffix=${{ matrix.node-version == 25 && '-node-25' || '' }} | ||
| 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' | ||
| strategy: | ||
| matrix: | ||
| node-version: [24, 25] | ||
| 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,linux/arm64 | ||
| 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 }} | ||