Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move drone to github action #101

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
./.dapper
./.cache
./dist
198 changes: 0 additions & 198 deletions .drone.yml

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Dev Build and Publish

on:
push:
branches:
- master

jobs:
build-for-dev:
uses: ./.github/workflows/factory.yaml
with:
tag: ${{ github.ref_name }}-head
push: true
secrets: inherit
57 changes: 57 additions & 0 deletions .github/workflows/factory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
workflow_call:
inputs:
tag:
required: true
type: string
push:
required: true
type: boolean

env:
repo: "rancher"
controllerImageName: "harvester-node-disk-manager"

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 (Controller)
uses: docker/build-push-action@v5
with:
provenance: false
context: .
platforms: linux/amd64,linux/arm64
file: package/Dockerfile
push: ${{ inputs.push }}
tags: ${{ env.repo }}/${{ env.controllerImageName }}:${{ inputs.tag }}
14 changes: 14 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Build and Publish

on:
push:
tags:
- v**

jobs:
build-for-release:
uses: ./.github/workflows/factory.yaml
with:
tag: ${{ github.ref_name }}
push: true
secrets: inherit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.dapper
/.cache
/bin
/dist
*.swp
.idea
9 changes: 6 additions & 3 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ RUN zypper -n rm container-suseconnect && \
## install golangci
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.1

## install controller-gen
# 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

## install controller-gen
RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2


# install openapi-gen
RUN go install k8s.io/code-generator/cmd/openapi-gen@v0.23.7

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS BUILD_FOR_CI
ENV DAPPER_SOURCE /go/src/github.com/harvester/node-disk-manager/
ENV DAPPER_OUTPUT ./bin ./dist ./manifests
ENV DAPPER_OUTPUT ./bin ./manifests
ENV DAPPER_DOCKER_SOCKET true
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Here we give the Sample XML for `libvirt` to create a SCSI device with `WWN`.
That has some limitations. For example, the UUID will be missed if the filesystem metadata is broken.

## License
Copyright (c) 2022 [Rancher Labs, Inc.](http://rancher.com)
Copyright (c) 2024 [Rancher Labs, Inc.](http://rancher.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 12 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1.7.0

FROM registry.suse.com/bci/bci-base:15.5

# util-linux-systemd -> for `lsblk` command
Expand All @@ -7,5 +9,14 @@ RUN zypper -n rm container-suseconnect && \
zypper -n install util-linux-systemd e2fsprogs iproute2 && \
zypper -n clean -a && rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/*

COPY bin/node-disk-manager /usr/bin/
ARG TARGETPLATFORM

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

ENV ARCH=${TARGETPLATFORM#linux/}

COPY bin/node-disk-manager-${ARCH} /usr/bin/node-disk-manager
CMD ["node-disk-manager"]
8 changes: 3 additions & 5 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ fi
LINKFLAGS="-X github.com/harvester/node-disk-manager/pkg/version.Version=$VERSION
-X github.com/harvester/node-disk-manager/pkg/version.GitCommit=$COMMIT $LINKFLAGS"

CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/node-disk-manager
if [ "$CROSS" = "true" ] && [ "$ARCH" = "amd64" ]; then
GOOS=darwin go build -ldflags "$LINKFLAGS" -o bin/node-disk-manager-darwin
GOOS=windows go build -ldflags "$LINKFLAGS" -o bin/node-disk-manager-windows
fi
Vicente-Cheng marked this conversation as resolved.
Show resolved Hide resolved
for arch in "amd64" "arm64"; do
GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/node-disk-manager-"$arch"
done
2 changes: 1 addition & 1 deletion scripts/entry
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

mkdir -p bin dist
mkdir -p bin
if [ -e ./scripts/$1 ]; then
./scripts/"$@"
else
Expand Down
5 changes: 1 addition & 4 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ source $(dirname $0)/version

cd $(dirname $0)/..

mkdir -p dist/artifacts
cp bin/node-disk-manager dist/artifacts/node-disk-manager${SUFFIX}

IMAGE=${REPO}/node-disk-manager:${TAG}
if [[ -n ${BUILD_FOR_CI} ]]; then
IMAGE=ttl.sh/node-disk-manager-${TAG}:1h
Expand All @@ -17,7 +14,7 @@ if [ -e ${DOCKERFILE}.${ARCH} ]; then
DOCKERFILE=${DOCKERFILE}.${ARCH}
fi

docker build -f ${DOCKERFILE} -t ${IMAGE} .
buildx build --load -f ${DOCKERFILE} -t ${IMAGE} .
echo Built ${IMAGE}
if [[ -n ${BUILD_FOR_CI} ]]; then
docker push ${IMAGE}
Expand Down
Loading