-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from jihoon-seo/210407-Update-build-and-publis…
…h-workflows Update build and publish workflows
- Loading branch information
Showing
4 changed files
with
149 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This workflow will build the container image for amd64 arch. (as a basic build test) | ||
name: Build amd64 container image | ||
|
||
on: | ||
# On pull-request event with detailed condition below. | ||
pull_request: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '**.md' | ||
- '.all-contributorsrc' | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- 'CODEOWNERS' | ||
|
||
jobs: | ||
# The job key is "building" | ||
building: | ||
# Job name is "Building" | ||
name: Building | ||
|
||
# This job runs on Ubuntu-latest | ||
runs-on: ubuntu-18.04 | ||
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
env: | ||
# TODO: Change variable to your repository name and image name. | ||
IMAGE_NAME: cb-webtool | ||
run: docker build . --file Dockerfile --tag $IMAGE_NAME |
This file was deleted.
Oops, something went wrong.
114 changes: 114 additions & 0 deletions
114
.github/workflows/publish-multi-arch-container-images.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# This workflow will build the container image and publish it to container registries. | ||
name: Publish multi-arch container images | ||
|
||
# When its time to do a release do a full cross platform build for all supported | ||
# architectures and push all of them to Docker Hub and GitHub Container Registry (GHCR). | ||
# Only trigger on semver shaped tags. | ||
on: | ||
# "Build and publish" on merged | ||
# Actually, there's no "merged" event. | ||
# A "push" event is occurred after the pull request "close" event with "merged" true condition. | ||
# The "push" event could replace "merged" event. | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*.*.*" | ||
paths-ignore: | ||
- '**.md' | ||
- '.all-contributorsrc' | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- 'CODEOWNERS' | ||
|
||
jobs: | ||
# The job key is "publishing" | ||
publishing: | ||
# Job name is "Publishing" | ||
name: Publishing | ||
|
||
# This job runs on Ubuntu-latest | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare tags | ||
id: prep | ||
env: | ||
# TODO: Change variable to your repository name and image name. | ||
DOCKER_REPO: cloudbaristaorg | ||
IMAGE_NAME: cb-webtool | ||
run: | | ||
VERSION=latest | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
fi | ||
if [ "${{ github.event_name }}" = "schedule" ]; then | ||
VERSION=nightly | ||
fi | ||
DOCKER_IMAGE=$DOCKER_REPO/$IMAGE_NAME | ||
DOCKER_TAGS="${DOCKER_IMAGE}:${VERSION}" | ||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*$ ]]; then | ||
DOCKER_TAGS="$DOCKER_TAGS,${DOCKER_IMAGE}:latest" | ||
fi | ||
echo ::set-output name=docker-tags::${DOCKER_TAGS} | ||
echo ${DOCKER_TAGS} | ||
GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | ||
GHCR_TAGS="${GHCR_IMAGE}:${VERSION}" | ||
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*$ ]]; then | ||
GHCR_TAGS="$GHCR_TAGS,${GHCR_IMAGE}:latest" | ||
fi | ||
echo ::set-output name=ghcr-tags::${GHCR_TAGS} | ||
echo ${GHCR_TAGS} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
with: | ||
platforms: all | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker layers | ||
uses: actions/[email protected] | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT` | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CR_PAT }} | ||
|
||
- name: Build and publish | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: ./ | ||
file: ./Dockerfile | ||
target: prod | ||
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6 | ||
push: true | ||
tags: | | ||
${{ steps.prep.outputs.docker-tags }} | ||
${{ steps.prep.outputs.ghcr-tags }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache | ||
|
||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters