fix: 添加 pull: true 确保拉取最新基础镜像 #8
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 Course Docker Image | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'checks/**' | |
| - 'Dockerfile' | |
| - '.github/workflows/docker.yml' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: bootcs-cn/bootcs-cli | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push CS50 image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| pull: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cs50 | |
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cs50-${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Test CS50 image | |
| run: | | |
| # 测试镜像版本 | |
| docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cs50 --version | |
| # 测试检查脚本存在(使用 --entrypoint 覆盖) | |
| docker run --rm --entrypoint ls ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cs50 /checks/ | |
| echo "CS50 image test passed!" |