Skip to content

Commit

Permalink
Merge pull request #416 from inductor/use_docker_action
Browse files Browse the repository at this point in the history
Use Docker action
  • Loading branch information
umezawatakeshi authored Jun 10, 2022
2 parents 1d02efd + aa6b38b commit bfe61f8
Showing 1 changed file with 62 additions and 15 deletions.
77 changes: 62 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,74 @@ on:
env:
go-version: 1.17
jobs:
image:
build-moco:
name: Push Container Image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Build images
run: |
docker build -t moco:dev --target controller .
docker build -t moco-backup:dev .
- name: Login to ghcr.io
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Push images
run: |
TAG=${GITHUB_REF#refs/tags/v}
docker tag moco:dev ghcr.io/cybozu-go/moco:$TAG
docker push ghcr.io/cybozu-go/moco:$TAG
docker tag moco-backup:dev ghcr.io/cybozu-go/moco-backup:$TAG
docker push ghcr.io/cybozu-go/moco-backup:$TAG
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/cybozu-go/moco
# ref. https://github.com/docker/metadata-action#typesemver
tags: |
type=semver,pattern={{version}}
- name: Build (and push if on main)
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
target: controller
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-moco-backup:
name: Push Container Image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/cybozu-go/moco-backup
# ref. https://github.com/docker/metadata-action#typesemver
tags: |
type=semver,pattern={{version}}
- name: Build (and push if on main)
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
name: Release on GitHub
needs: image
needs: [build-moco, build-moco-backup]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit bfe61f8

Please sign in to comment.