Skip to content

Commit 918e0bb

Browse files
committed
ci: create GHA for build
- Also, remove the redundant GHA Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
1 parent 7116fef commit 918e0bb

File tree

11 files changed

+132
-237
lines changed

11 files changed

+132
-237
lines changed

.github/release-drafter.yml

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

.github/workflows/codeql-analysis.yml

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

.github/workflows/dev.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Dev Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build-for-dev:
10+
uses: ./.github/workflows/factory.yml
11+
with:
12+
tag: ${{ github.ref_name }}-head
13+
push: true
14+
secrets: inherit

.github/workflows/docker.yaml

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

.github/workflows/factory.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
tag:
5+
required: true
6+
type: string
7+
push:
8+
required: true
9+
type: boolean
10+
11+
env:
12+
repo: "rancher"
13+
provisionerImageName: "harvester-lvm-provisioner"
14+
pluginImageName: "harvester-lvm-csi-plugin"
15+
16+
jobs:
17+
dapper-build:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
id-token: write
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Run dapper
33+
run: make ci
34+
35+
- name: Read some Secrets
36+
uses: rancher-eio/read-vault-secrets@main
37+
if: ${{ inputs.push == true }}
38+
with:
39+
secrets: |
40+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
41+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
42+
- name: Login to Docker Hub
43+
uses: docker/login-action@v3
44+
if: ${{ inputs.push == true }}
45+
with:
46+
username: ${{ env.DOCKER_USERNAME }}
47+
password: ${{ env.DOCKER_PASSWORD }}
48+
49+
- name: Docker Build (CSI Plugin)
50+
uses: docker/build-push-action@v5
51+
with:
52+
provenance: false
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
file: package/Dockerfile
56+
push: ${{ inputs.push }}
57+
tags: ${{ env.repo }}/${{ env.pluginImageName }}:${{ inputs.tag }}
58+
59+
- name: Docker Build (LVM Provisioner)
60+
uses: docker/build-push-action@v5
61+
with:
62+
provenance: false
63+
context: .
64+
platforms: linux/amd64,linux/arm64
65+
file: package/Dockerfile.provisioner
66+
push: ${{ inputs.push }}
67+
tags: ${{ env.repo }}/${{ env.provisionerImageName }}:${{ inputs.tag }}

.github/workflows/pr.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Pull Request Build
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
build-for-PR:
9+
uses: ./.github/workflows/factory.yml
10+
with:
11+
tag: pr-${{ github.event.number }}
12+
push: false
13+
secrets: inherit

.github/workflows/release-drafter.yaml

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

.github/workflows/release.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Build and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- v**
7+
8+
jobs:
9+
build-for-release:
10+
uses: ./.github/workflows/factory.yml
11+
with:
12+
tag: ${{ github.ref_name }}
13+
push: true
14+
secrets: inherit

package/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,14 @@ RUN zypper -n rm container-suseconnect && \
44
zypper -n install util-linux-systemd lvm2 e2fsprogs nvme-cli device-mapper xfsprogs && \
55
zypper -n clean -a && rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/*
66

7-
COPY bin/lvmplugin /usr/bin/
7+
ARG TARGETPLATFORM
8+
9+
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
10+
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
11+
exit 1; \
12+
fi
13+
14+
ENV ARCH=${TARGETPLATFORM#linux/}
15+
16+
COPY bin/lvmplugin-${ARCH} /usr/bin/
817
ENTRYPOINT ["lvmplugin"]

package/Dockerfile.provisioner

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ RUN zypper -n rm container-suseconnect && \
44
zypper -n install lvm2 e2fsprogs smartmontools nvme-cli device-mapper && \
55
zypper -n clean -a && rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/*
66

7-
COPY bin/csi-lvmplugin-provisioner /csi-lvmplugin-provisioner
7+
ARG TARGETPLATFORM
8+
9+
RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
10+
echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \
11+
exit 1; \
12+
fi
13+
14+
ENV ARCH=${TARGETPLATFORM#linux/}
15+
COPY bin/csi-lvmplugin-provisioner-${ARCH} /csi-lvmplugin-provisioner
816
USER root
9-
ENTRYPOINT ["csi-lvmplugin-provisioner"]
17+
ENTRYPOINT ["csi-lvmplugin-provisioner"]

scripts/build

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ fi
1313
LINKFLAGS="-X github.com/hravester/csi-driver-lvm/pkg/version.Version=$VERSION
1414
-X github.com/harvester/csi-driver-lvm/pkg/version.GitCommit=$COMMIT $LINKFLAGS"
1515

16-
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/lvmplugin
17-
CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/csi-lvmplugin-provisioner cmd/provisioner/*.go
16+
for arch in "amd64" "arm64"; do
17+
GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/lvmplugin-"$arch"
18+
GOARCH="$arch" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o bin/csi-lvmplugin-provisioner-"$arch" cmd/provisioner/*.go
19+
done

0 commit comments

Comments
 (0)