Skip to content

Commit

Permalink
migrate from drone to gh actions (#29)
Browse files Browse the repository at this point in the history
* migrte from drone to gh actions

* increase golangci-lint timeout

* missing changes needed for cross-compilation and image builds
  • Loading branch information
ibrokethecloud authored Apr 24, 2024
1 parent 6f07c18 commit 94b9fec
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 79 deletions.
74 changes: 0 additions & 74 deletions .drone.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Master Build and Publish

on:
push:
branches:
- master
- release/v*

jobs:
build-master:
uses: ./.github/workflows/template-build.yml
with:
release-tag-name: ${{ github.ref_name }}-head
push: true
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Pull Request Build

on:
pull_request:

jobs:
build-pr:
uses: ./.github/workflows/template-build.yml
with:
release-tag-name: pull-${{ github.event.number }}
push: false
secrets: inherit
14 changes: 14 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Tag Build and Publish

on:
push:
tags:
- v*

jobs:
build-tag:
uses: ./.github/workflows/template-build.yml
with:
release-tag-name: ${{ github.ref_name }}
push: true
secrets: inherit
57 changes: 57 additions & 0 deletions .github/workflows/template-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
workflow_call:
inputs:
release-tag-name:
required: true
type: string
push:
required: true
type: boolean
env:
imageName: "rancher/harvester-seeder"

jobs:
dapper-build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run dapper
run: make ci

- name: Read some Secrets
uses: rancher-eio/read-vault-secrets@main
if: ${{ inputs.push == true }}
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ inputs.push == true }}
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Docker Build
uses: docker/build-push-action@v5
with:
provenance: false
context: .
platforms: linux/amd64,linux/arm64
file: package/Dockerfile
push: ${{ inputs.push }}
tags: ${{env.imageName}}:${{ inputs.release-tag-name }}
build-args: |
VERSION=${{ github.ref_name }}-${{ github.sha }}-head
6 changes: 5 additions & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ RUN if [ "${ARCH}" = "amd64" ]; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.1; \
fi


# The docker version in dapper is too old to have buildx. Install it manually.
RUN curl -sSfL https://github.com/docker/buildx/releases/download/v0.13.1/buildx-v0.13.1.linux-${ARCH} -o buildx-v0.13.1.linux-${ARCH} && \
chmod +x buildx-v0.13.1.linux-${ARCH} && \
mv buildx-v0.13.1.linux-${ARCH} /usr/local/bin/buildx

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS SKIPINDRONE
ENV DAPPER_SOURCE /go/src/github.com/harvester/seeder
ENV DAPPER_OUTPUT ./bin ./pkg/api ./config
Expand Down
12 changes: 11 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# syntax=docker/dockerfile:1.7.0

# Build the manager binary
FROM registry.suse.com/bci/bci-base:15.5
RUN zypper -n install ipmitool=1.8.18.238.gb7adc1d-150400.3.6.1 && zypper clean
ARG TARGETPLATFORM

RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
exit 1; \
fi

ENV ARCH=${TARGETPLATFORM#linux/}
WORKDIR /
COPY bin/manager /bin/manager
COPY bin/manager-${ARCH} /bin/manager
USER 65532:65532

ENTRYPOINT ["/bin/manager"]
3 changes: 2 additions & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ cd $(dirname $0)/..
go fmt ./...
go vet ./...
go generate ./...
CGO_ENABLED=0 go build -o bin/manager .
GOARCH=amd64 CGO_ENABLED=0 go build -o bin/manager-amd64 .
GOARCH=arm64 CGO_ENABLED=0 go build -o bin/manager-arm64 .
mkdir -p bin
4 changes: 3 additions & 1 deletion scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ fi
IMAGE=${REPO}/harvester-seeder:${TAG}
DOCKERFILE=package/Dockerfile

docker build -f ${DOCKERFILE} -t ${IMAGE} .
buildx build --load \
-f ${DOCKERFILE} -t ${IMAGE} .

echo Built ${IMAGE}
2 changes: 1 addition & 1 deletion scripts/validate
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ if [[ -z "$(command -v golangci-lint)" ]]; then
fi

echo "Running: golangci-lint run"
golangci-lint run
golangci-lint run --timeout 10m

0 comments on commit 94b9fec

Please sign in to comment.