Skip to content

Commit 83af8c5

Browse files
authored
Feature/add ci (#2)
1 parent 791edc8 commit 83af8c5

File tree

7 files changed

+136
-0
lines changed

7 files changed

+136
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.github/
2+
bin/

.github/workflows/pr.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: PR Build
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Docker
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Set up QEMU
11+
uses: docker/setup-qemu-action@v1
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v1
14+
- name: Login to DockerHub
15+
uses: docker/login-action@v1
16+
with:
17+
username: ${{ secrets.DOCKERHUB_USERNAME }}
18+
password: ${{ secrets.DOCKERHUB_TOKEN }}
19+
- name: Build and Push
20+
id: docker_build
21+
uses: docker/build-push-action@v2
22+
with:
23+
push: false

.github/workflows/release.yml

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Create Release
2+
3+
# on: push
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
build:
11+
name: Docker
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set RELEASE_STRING
15+
run: echo "RELEASE_STRING=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
16+
# run: echo "RELEASE_STRING=0.0.1-dev" >> $GITHUB_ENV
17+
- name: Set RELEASE_VERSION
18+
run: echo "RELEASE_VERSION=v${RELEASE_STRING}" >> $GITHUB_ENV
19+
- name: Set up QEMU
20+
uses: docker/setup-qemu-action@v1
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v1
23+
- name: Login to DockerHub
24+
uses: docker/login-action@v1
25+
with:
26+
username: ${{ secrets.DOCKERHUB_USERNAME }}
27+
password: ${{ secrets.DOCKERHUB_TOKEN }}
28+
- name: Build and Push
29+
id: docker_build
30+
uses: docker/build-push-action@v2
31+
with:
32+
build-args: |
33+
RELEASE_STRING=${{ env.RELEASE_STRING }}
34+
push: true
35+
tags: |
36+
plumbit/kubernetes-dynamic-reclaimable-pvc-controllers:${{ env.RELEASE_VERSION }}
37+
plumbit/kubernetes-dynamic-reclaimable-pvc-controllers:latest
38+
- name: Image digest
39+
run: echo ${{ steps.docker_build.outputs.digest }}
40+
# See https://github.com/peter-evans/dockerhub-description/issues/10
41+
# - name: Checkout Code
42+
# uses: actions/checkout@v2
43+
# - name: Docker Hub Description
44+
# uses: peter-evans/dockerhub-description@v2
45+
# with:
46+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
47+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
48+
# short-description: Dynamic PVC provisioner for pods and jobs requesting it via annotations. Automatic PV releaser.
49+
# repository: plumbit/kubernetes-dynamic-reclaimable-pvc-controllers
50+
release:
51+
name: Release
52+
if: startsWith(github.ref, 'refs/tags/')
53+
runs-on: ubuntu-latest
54+
needs: build
55+
steps:
56+
- name: Checkout Code
57+
uses: actions/checkout@v2
58+
- name: Release
59+
uses: docker://antonyurchenko/git-release:v3
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
DRAFT_RELEASE: "false"
63+
PRE_RELEASE: "false"
64+
CHANGELOG_FILE: "CHANGELOG.md"
65+
ALLOW_EMPTY_CHANGELOG: "false"
66+
ALLOW_TAG_PREFIX: "true"

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.0.1] - 2021-06-19
11+
12+
### Added
13+
14+
- Initial implementation

Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:1.16 AS build
2+
3+
ARG RELEASE_STRING=dev
4+
ENV IMPORT_PATH="github.com/plumber-cd/kubernetes-dynamic-reclaimable-pvc-controllers"
5+
WORKDIR /go/delivery
6+
COPY . .
7+
RUN mkdir bin && go build \
8+
-ldflags "-X ${IMPORT_PATH}.Version=${RELEASE_STRING}" \
9+
-o ./bin ./...
10+
11+
FROM debian:buster
12+
13+
COPY --from=build /go/delivery/bin /usr/bin

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
Dynamic PVC provisioner for pods requesting it via annotations. Automatic PV releaser.
44

5+
- [kubernetes-dynamic-reclaimable-pvc-controllers](#kubernetes-dynamic-reclaimable-pvc-controllers)
6+
- [Features](#features)
7+
- [Disclaimers](#disclaimers)
8+
- [PVC Provisioner Controller](#pvc-provisioner-controller)
9+
- [Provision](#provision)
10+
- [Usage](#usage)
11+
- [PV Releaser Controller](#pv-releaser-controller)
12+
- [Associate](#associate)
13+
- [Release](#release)
14+
- [Usage](#usage-1)
15+
516
## Features
617

718
- PVC Provisioner

controller.go

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import (
3939
"k8s.io/client-go/util/workqueue"
4040
)
4141

42+
var Version string
43+
4244
func buildConfig(kubeconfig string) (*rest.Config, error) {
4345
if kubeconfig != "" {
4446
klog.V(2).Infof("Using kubeconfig %s", kubeconfig)
@@ -120,6 +122,11 @@ func Main(
120122
})
121123
klog.V(2).Infof("Args: %s", flag.Args())
122124

125+
if len(flag.Args()) == 1 && flag.Args()[0] == "version" {
126+
fmt.Println(Version)
127+
os.Exit(0)
128+
}
129+
123130
if controllerId == "" {
124131
klog.Fatal("unable to get controller id (missing controller-id flag).")
125132
}

0 commit comments

Comments
 (0)