Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Docker action #416

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also test docker build on each commit if you set this as false on other action triggers.

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