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

Commit 935b358

Browse files
authored
Github action with multi-CPU architecture support and multi docker file support (#30)
Github action with multi-CPU architecture support and multi docker file support (#30)
1 parent 49c7223 commit 935b358

File tree

417 files changed

+277
-200558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+277
-200558
lines changed

.github/workflows/build.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#
2+
# Copyright (c) 2020 Red Hat, Inc.
3+
# This program and the accompanying materials are made
4+
# available under the terms of the Eclipse Public License 2.0
5+
# which is available at https://www.eclipse.org/legal/epl-2.0/
6+
#
7+
# SPDX-License-Identifier: EPL-2.0
8+
#
9+
# Contributors:
10+
# Red Hat, Inc. - initial API and implementation
11+
#
12+
13+
name: build
14+
15+
on:
16+
push:
17+
branches:
18+
- 'master'
19+
- 'v*'
20+
tags:
21+
- 'v*'
22+
paths-ignore:
23+
- '**.md'
24+
pull_request:
25+
branches:
26+
- 'master'
27+
- 'v*'
28+
paths-ignore:
29+
- '**.md'
30+
31+
jobs:
32+
33+
go:
34+
runs-on: ubuntu-latest
35+
steps:
36+
-
37+
name: Checkout
38+
uses: actions/checkout@v2.3.1
39+
-
40+
name: Prepare
41+
id: prepare
42+
run: |
43+
if [[ $GITHUB_REF == refs/tags/* ]]; then
44+
echo ::set-output name=tag_name::${GITHUB_REF#refs/tags/}
45+
fi
46+
-
47+
name: Set up Go
48+
uses: actions/setup-go@v2
49+
with:
50+
go-version: 1.13
51+
-
52+
name: Cache Go modules
53+
uses: actions/cache@v2
54+
with:
55+
path: ~/go/pkg/mod
56+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
57+
restore-keys: |
58+
${{ runner.os }}-go-
59+
-
60+
name: Go mod
61+
run: go mod download
62+
-
63+
name: Go test
64+
run: go test -v ./...
65+
docker:
66+
runs-on: ubuntu-18.04
67+
needs: go
68+
steps:
69+
-
70+
name: Checkout
71+
uses: actions/checkout@v2.3.1
72+
-
73+
name: Prepare
74+
id: prepare
75+
run: |
76+
DOCKER_USERNAME=${{secrets.DOCKER_USERNAME}}
77+
DOCKER_IMAGE=${{secrets.DOCKER_IMAGE}}
78+
DOCKER_IMAGE=${DOCKER_IMAGE:-$GITHUB_REPOSITORY}
79+
DOCKER_REPO=${{secrets.DOCKER_REPO}}
80+
DOCKER_PLATFORMS=linux/amd64,linux/s390x,linux/arm64,linux/ppc64le
81+
VERSION=latest
82+
83+
if [[ $GITHUB_REF == refs/tags/* ]]; then
84+
VERSION=${GITHUB_REF#refs/tags/v}
85+
fi
86+
87+
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
88+
TAGS_RHEL="--tag ${DOCKER_IMAGE}:${VERSION}-rhel"
89+
90+
echo ::set-output name=docker_username::${DOCKER_USERNAME}
91+
echo ::set-output name=docker_repo::${DOCKER_REPO}
92+
echo ::set-output name=docker_image::${DOCKER_IMAGE}
93+
echo ::set-output name=version::${VERSION}
94+
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
95+
--build-arg VERSION=${VERSION} \
96+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
97+
--build-arg VCS_REF=${GITHUB_SHA::8} \
98+
${TAGS} --file build/dockerfiles/Dockerfile .
99+
100+
echo ::set-output name=buildx_args_rhel::--platform linux/amd64 \
101+
--build-arg VERSION=${VERSION} \
102+
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
103+
--build-arg VCS_REF=${GITHUB_SHA::8} \
104+
${TAGS_RHEL} --file build/dockerfiles/rhel.Dockerfile .
105+
-
106+
name: Set up Docker Buildx
107+
uses: crazy-max/ghaction-docker-buildx@v3.2.0
108+
with:
109+
buildx-version: v0.4.1
110+
-
111+
name: Docker Buildx (build)
112+
run: |
113+
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
114+
-
115+
name: Docker Login
116+
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
117+
env:
118+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
119+
run: |
120+
echo "${DOCKER_PASSWORD}" | docker login ${{ steps.prepare.outputs.docker_repo }} --username "${{ steps.prepare.outputs.docker_username }}" --password-stdin
121+
-
122+
name: Docker Buildx (push)
123+
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
124+
run: |
125+
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
126+
-
127+
name: Docker Buildx rhel (push)
128+
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
129+
run: |
130+
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args_rhel }}
131+
-
132+
name: Docker Check Manifest
133+
if: success() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
134+
run: |
135+
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
136+
-
137+
name: Clear
138+
if: always() && github.event_name != 'pull_request' && (endsWith(github.ref, github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/'))
139+
run: |
140+
rm -f ${HOME}/.docker/config.json

.travis.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

Gopkg.lock

Lines changed: 0 additions & 113 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)