github.com/containerd/nerdctl@v1.7.7/.github/workflows/ghcr-image-build-and-publish.yml (about) 1 name: Container Image Build 2 3 # This workflow uses actions that are not certified by GitHub. 4 # They are provided by a third-party and are governed by 5 # separate terms of service, privacy policy, and support 6 # documentation. 7 8 on: 9 push: 10 branches: [main] 11 # Publish semver tags as releases. 12 tags: ['v*.*.*'] 13 pull_request: 14 branches: [main] 15 16 env: 17 # Use docker.io for Docker Hub if empty 18 REGISTRY: ghcr.io 19 # github.repository as <account>/<repo> 20 IMAGE_NAME: ${{ github.repository }} 21 22 23 jobs: 24 build: 25 26 runs-on: ubuntu-24.04 27 permissions: 28 contents: read 29 packages: write 30 31 steps: 32 - name: Checkout repository 33 uses: actions/checkout@v4.1.1 34 35 - name: Set up QEMU 36 uses: docker/setup-qemu-action@v3 37 38 - name: Set up Docker Buildx 39 uses: docker/setup-buildx-action@v3 40 41 # Login against a Docker registry except on PR 42 # https://github.com/docker/login-action 43 - name: Log into registry ${{ env.REGISTRY }} 44 if: github.event_name != 'pull_request' 45 uses: docker/login-action@v3.0.0 46 with: 47 registry: ${{ env.REGISTRY }} 48 username: ${{ github.actor }} 49 password: ${{ secrets.GITHUB_TOKEN }} 50 51 # Extract metadata (tags, labels) for Docker 52 # https://github.com/docker/metadata-action 53 - name: Extract Docker metadata 54 id: meta 55 uses: docker/metadata-action@v5.5.0 56 with: 57 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 58 59 # Build and push Docker image with Buildx (don't push on PR) 60 # https://github.com/docker/build-push-action 61 - name: Build and push Docker image 62 uses: docker/build-push-action@v5.1.0 63 with: 64 context: . 65 platforms: linux/amd64,linux/arm64 66 push: ${{ github.event_name != 'pull_request' }} 67 tags: ${{ steps.meta.outputs.tags }} 68 labels: ${{ steps.meta.outputs.labels }}