Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
Github action with multi-CPU architecture support and multi docker fi…
Browse files Browse the repository at this point in the history
…le support (#30)

Github action with multi-CPU architecture support and multi docker file support (#30)
  • Loading branch information
skabashnyuk authored Aug 10, 2020
1 parent 49c7223 commit 935b358
Show file tree
Hide file tree
Showing 417 changed files with 277 additions and 200,558 deletions.
140 changes: 140 additions & 0 deletions .github/workflows/build.yml
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
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

113 changes: 0 additions & 113 deletions Gopkg.lock

This file was deleted.

42 changes: 0 additions & 42 deletions Gopkg.toml

This file was deleted.

Loading

0 comments on commit 935b358

Please sign in to comment.