This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github action with multi-CPU architecture support and multi docker fi…
…le support (#30) Github action with multi-CPU architecture support and multi docker file support (#30)
- Loading branch information
1 parent
49c7223
commit 935b358
Showing
417 changed files
with
277 additions
and
200,558 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,140 @@ | ||
# | ||
# Copyright (c) 2020 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'v*' | ||
tags: | ||
- 'v*' | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
branches: | ||
- 'master' | ||
- 'v*' | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
|
||
go: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/[email protected] | ||
- | ||
name: Prepare | ||
id: prepare | ||
run: | | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
echo ::set-output name=tag_name::${GITHUB_REF#refs/tags/} | ||
fi | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.13 | ||
- | ||
name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- | ||
name: Go mod | ||
run: go mod download | ||
- | ||
name: Go test | ||
run: go test -v ./... | ||
docker: | ||
runs-on: ubuntu-18.04 | ||
needs: go | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/[email protected] | ||
- | ||
name: Prepare | ||
id: prepare | ||
run: | | ||
DOCKER_USERNAME=${{secrets.DOCKER_USERNAME}} | ||
DOCKER_IMAGE=${{secrets.DOCKER_IMAGE}} | ||
DOCKER_IMAGE=${DOCKER_IMAGE:-$GITHUB_REPOSITORY} | ||
DOCKER_REPO=${{secrets.DOCKER_REPO}} | ||
DOCKER_PLATFORMS=linux/amd64,linux/s390x,linux/arm64,linux/ppc64le | ||
VERSION=latest | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
fi | ||
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}" | ||
TAGS_RHEL="--tag ${DOCKER_IMAGE}:${VERSION}-rhel" | ||
echo ::set-output name=docker_username::${DOCKER_USERNAME} | ||
echo ::set-output name=docker_repo::${DOCKER_REPO} | ||
echo ::set-output name=docker_image::${DOCKER_IMAGE} | ||
echo ::set-output name=version::${VERSION} | ||
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ | ||
--build-arg VERSION=${VERSION} \ | ||
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | ||
--build-arg VCS_REF=${GITHUB_SHA::8} \ | ||
${TAGS} --file build/dockerfiles/Dockerfile . | ||
echo ::set-output name=buildx_args_rhel::--platform linux/amd64 \ | ||
--build-arg VERSION=${VERSION} \ | ||
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | ||
--build-arg VCS_REF=${GITHUB_SHA::8} \ | ||
${TAGS_RHEL} --file build/dockerfiles/rhel.Dockerfile . | ||
- | ||
name: Set up Docker Buildx | ||
uses: crazy-max/[email protected] | ||
with: | ||
buildx-version: v0.4.1 | ||
- | ||
name: Docker Buildx (build) | ||
run: | | ||
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} | ||
- | ||
name: Docker Login | ||
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | ||
env: | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login ${{ steps.prepare.outputs.docker_repo }} --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin | ||
- | ||
name: Docker Buildx (push) | ||
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | ||
run: | | ||
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} | ||
- | ||
name: Docker Buildx rhel (push) | ||
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | ||
run: | | ||
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args_rhel }} | ||
- | ||
name: Docker Check Manifest | ||
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | ||
run: | | ||
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} | ||
- | ||
name: Clear | ||
if: always() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | ||
run: | | ||
rm -f ${HOME}/.docker/config.json |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.