Skip to content

Commit

Permalink
コンテナイメージのCI (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net authored Jun 29, 2024
1 parent d6cf806 commit de21d68
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/docker-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

env:
REGISTRY_IMAGE: noridev/cherrypick
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
# see https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
Expand All @@ -20,7 +20,7 @@ jobs:
platform:
- linux/amd64
- linux/arm64
if: github.repository == 'kokonect-link/cherrypick'
if: github.repository == 'yojo-art/cherrypick'
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
Expand All @@ -41,11 +41,12 @@ jobs:
uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
Expand Down Expand Up @@ -84,11 +85,13 @@ jobs:
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tags: ${{ env.REGISTRY_IMAGE }}:develop
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
Expand Down
46 changes: 16 additions & 30 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Publish Docker image

on:
Expand All @@ -6,14 +7,7 @@ on:
workflow_dispatch:

env:
REGISTRY_IMAGE: noridev/cherrypick
TAGS: |
type=edge
type=ref,event=pr
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
# see https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
Expand All @@ -26,6 +20,7 @@ jobs:
platform:
- linux/amd64
- linux/arm64
if: github.repository == 'yojo-art/cherrypick'
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
Expand All @@ -46,26 +41,21 @@ jobs:
uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: ${{ env.TAGS }}
- name: Log in to Docker Hub
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push to Docker Hub
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: ${{ matrix.platform }}
provenance: false
labels: ${{ steps.meta.outputs.labels }}
labels: master
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
Expand Down Expand Up @@ -95,22 +85,18 @@ jobs:
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: ${{ env.TAGS }}
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tags: ${{ env.REGISTRY_IMAGE }}:${GITHUB_REF/refs\/tags\//}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
docker buildx imagetools create --tag ${{ env.REGISTRY_IMAGE }}:${GITHUB_REF/refs\/tags\//} \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${GITHUB_REF/refs\/tags\//}

0 comments on commit de21d68

Please sign in to comment.