Files
moyu-qile/.github/workflows/docker-publish.yml
T

58 lines
1.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish Docker image to GHCR
on:
push:
branches: [master]
paths:
- 'Dockerfile'
- 'server.js'
- 'package.json'
- 'app/**'
- '.github/workflows/docker-publish.yml'
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
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@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/moyu-qile:latest
ghcr.io/${{ github.repository_owner }}/moyu-qile:${{ github.run_number }}
ghcr.io/${{ github.repository_owner }}/moyu-qile:20261008
- name: Make package public (anonymous pull)
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api -X PATCH "/user/packages/container/moyu-qile" -f visibility=public \
&& echo "✅ 已设为 public" \
|| echo "⚠️ 未能通过 API 设为 public(若匿名拉取失败,需在 GitHub → Packages → moyu-qile 手动改为 Public)"
- name: Verify anonymous pull
continue-on-error: true
run: |
docker logout ghcr.io
docker manifest inspect ghcr.io/${{ github.repository_owner }}/moyu-qile:latest >/dev/null \
&& echo "✅ 匿名可拉取(public 生效)" \
|| echo "⚠️ 匿名仍不可拉取(包还是 private)"