Skip to content

Commit 0190cce

Browse files
Merge pull request #25 from thomasferrandiz/migrateToGHA
Migrate to Github Actions
2 parents 59ce75a + 85ec754 commit 0190cce

File tree

6 files changed

+129
-172
lines changed

6 files changed

+129
-172
lines changed

.drone.yml

-144
This file was deleted.

.github/workflows/build.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
security-events: write # upload Sarif results
10+
11+
name: Build
12+
jobs:
13+
build-amd64:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set the TAG value
20+
id: get-TAG
21+
run: |
22+
echo "$(make -s log | grep TAG)" >> "$GITHUB_ENV"
23+
- name: Build container image
24+
uses: docker/build-push-action@v5
25+
with:
26+
context: .
27+
push: false
28+
tags: rancher/hardened-crictl:${{ env.TAG }}-amd64
29+
file: Dockerfile
30+
31+
- name: Run Trivy vulnerability scanner
32+
uses: aquasecurity/trivy-action@0.18.0
33+
with:
34+
image-ref: rancher/hardened-crictl:${{ env.TAG }}-amd64
35+
ignore-unfixed: true
36+
vuln-type: 'os,library'
37+
severity: 'CRITICAL,HIGH'
38+
format: 'sarif'
39+
output: 'trivy-results.sarif'
40+
- name: Upload Trivy scan results to GitHub Security tab
41+
uses: github/codeql-action/upload-sarif@v3
42+
if: always()
43+
with:
44+
sarif_file: 'trivy-results.sarif'
45+
46+
build-arm64:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Check out code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
58+
- name: Set the TAG value
59+
id: get-TAG
60+
run: |
61+
echo "$(make -s log | grep TAG)" >> "$GITHUB_ENV"
62+
- name: Build container image
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
push: false
67+
tags: rancher/hardened-crictl:${{ env.TAG }}-arm64
68+
file: Dockerfile
69+
outputs: type=docker
70+
platforms: linux/arm64

.github/workflows/image-push.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
on:
2+
release:
3+
types: [published]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
push-multiarch:
10+
permissions:
11+
contents: read
12+
id-token: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: "Read secrets"
22+
uses: rancher-eio/read-vault-secrets@main
23+
with:
24+
secrets: |
25+
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials username | DOCKER_USERNAME ;
26+
secret/data/github/repo/${{ github.repository }}/dockerhub/${{ github.repository_owner }}/credentials password | DOCKER_PASSWORD
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Login to Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ env.DOCKER_USERNAME }}
35+
password: ${{ env.DOCKER_PASSWORD }}
36+
37+
- name: Build container image
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
push: true
42+
tags: rancher/hardened-crictl:${{ github.event.release.tag_name }}
43+
file: Dockerfile
44+
platforms: linux/amd64, linux/arm64

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG BCI_IMAGE=registry.suse.com/bci/bci-base
2-
ARG GO_IMAGE=rancher/hardened-build-base:1.20.4b11
2+
ARG GO_IMAGE=rancher/hardened-build-base:v1.20.4b11
33
FROM ${BCI_IMAGE} as bci
44
FROM ${GO_IMAGE} as builder
55
# setup required packages

Makefile

+14-15
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,40 @@ PKG ?= github.com/kubernetes-sigs/cri-tools
1616
SRC ?= github.com/kubernetes-sigs/cri-tools
1717
TAG ?= v1.26.1$(BUILD_META)
1818

19-
ifneq ($(DRONE_TAG),)
20-
TAG := $(DRONE_TAG)
21-
endif
22-
2319
ifeq (,$(filter %$(BUILD_META),$(TAG)))
24-
$(error TAG needs to end with build metadata: $(BUILD_META))
20+
$(error TAG needs to end with build metadata: $(BUILD_META))
2521
endif
2622

2723
GOLANG_VERSION := $(shell ./scripts/golang-version.sh $(TAG))
2824

2925
.PHONY: image-build
3026
image-build:
31-
docker build \
27+
docker buildx build \
28+
--platform=$(ARCH) \
3229
--pull \
3330
--build-arg PKG=$(PKG) \
3431
--build-arg SRC=$(SRC) \
3532
--build-arg TAG=$(TAG:$(BUILD_META)=) \
3633
--build-arg ARCH=$(ARCH) \
37-
--build-arg GO_IMAGE=rancher/hardened-build-base:$(GOLANG_VERSION) \
3834
--tag $(ORG)/hardened-crictl:$(TAG) \
3935
--tag $(ORG)/hardened-crictl:$(TAG)-$(ARCH) \
36+
--load \
4037
.
4138

4239
.PHONY: image-push
4340
image-push:
4441
docker push $(ORG)/hardened-crictl:$(TAG)-$(ARCH)
4542

46-
.PHONY: image-manifest
47-
image-manifest:
48-
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create --amend \
49-
$(ORG)/hardened-crictl:$(TAG) \
50-
$(ORG)/hardened-crictl:$(TAG)-$(ARCH)
51-
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push \
52-
$(ORG)/hardened-crictl:$(TAG)
53-
5443
.PHONY: image-scan
5544
image-scan:
5645
trivy --severity $(SEVERITIES) --no-progress --ignore-unfixed $(ORG)/hardened-crictl:$(TAG)
46+
47+
PHONY: log
48+
log:
49+
@echo "ARCH=$(ARCH)"
50+
@echo "TAG=$(TAG)"
51+
@echo "ORG=$(ORG)"
52+
@echo "PKG=$(PKG)"
53+
@echo "SRC=$(SRC)"
54+
@echo "BUILD_META=$(BUILD_META)"
55+
@echo "UNAME_M=$(UNAME_M)"

manifest.tmpl

-12
This file was deleted.

0 commit comments

Comments
 (0)