From df451b41dff7aef2215db6f3f47c93a6ce01dc59 Mon Sep 17 00:00:00 2001 From: Zhang Jian <42706238+maxage@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:16:50 +0800 Subject: [PATCH] Create docker-ghcr.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 创建docker镜像工作流 --- .../.github/workflows/docker-ghcr.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/.github/workflows/docker-ghcr.yaml diff --git a/.github/workflows/.github/workflows/docker-ghcr.yaml b/.github/workflows/.github/workflows/docker-ghcr.yaml new file mode 100644 index 00000000000..db58d8d88c6 --- /dev/null +++ b/.github/workflows/.github/workflows/docker-ghcr.yaml @@ -0,0 +1,63 @@ +name: Docker ghcr.io + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + push: + branches: [main] + # Publish semver tags as releases. + tags: ["v*.*.*"] + pull_request: + branches: [main] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}