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

Add GitHub actions #9

Merged
merged 2 commits into from
Jun 19, 2023
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
24 changes: 24 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: ":seedling:"
labels:
- "ok-to-test"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: ":seedling:"
labels:
- "ok-to-test"
ignore:
# Ignore k8s and its transitives modules as they are upgraded manually
# together with controller-runtime.
- dependency-name: "k8s.io/*"
- dependency-name: "go.etcd.io/*"
- dependency-name: "google.golang.org/grpc"
36 changes: 36 additions & 0 deletions .github/workflows/container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: container-image

on:
push:
branches:
- main

jobs:
main-image:
name: build "main" image
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "^1.18"

- name: Create Licenses Report
run: |
make licenses-report

- name: Login to GitHub Container Registry
uses: docker/login-action@v2.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
tags: ghcr.io/telekom/das-schiff-network-operator:main
71 changes: 71 additions & 0 deletions .github/workflows/draft_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Create Draft Release

on:
push:
tags:
- "v*"

jobs:
draft_release:
name: Create Draft Release
runs-on: ubuntu-latest
steps:
# - name: Set env
# run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Checkout the Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "^1.18"
# - name: generate release notes
# run: |
# make release-notes
- name: Create Licenses Report
run: |
make licenses-report
- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: out/*.*
# body_path: _releasenotes/${{ env.RELEASE_TAG }}.md

release_image:
name: Build and Push Release Image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "^1.18"

- name: Create Licenses Report
run: |
make licenses-report

- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.4.0
with:
images: ghcr.io/telekom/das-schiff-network-operator

- name: Build and Push Docker Image
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.so
*.dylib
bin
out
testbin/*

# Test binary, build with `go test -c`
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ docker-build: test ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}

##@ Release

RELEASE_DIR ?= out

$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)/

licenses-report: go-licenses
rm -rf $(RELEASE_DIR)/licenses
$(GO_LICENSES) save --save_path $(RELEASE_DIR)/licenses ./...
$(GO_LICENSES) report --template hack/licenses.md.tpl ./... > $(RELEASE_DIR)/licenses/licenses.md
(cd out/licenses && tar -czf ../licenses.tar.gz *)

##@ Deployment

ifndef ignore-not-found
Expand Down Expand Up @@ -119,6 +132,11 @@ ENVTEST = $(shell pwd)/bin/setup-envtest
envtest: ## Download envtest-setup locally if necessary.
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

GO_LICENSES = $(shell pwd)/bin/go-licenses
.PHONY: go-licenses
go-licenses: ## Download go-licenses locally if necessary.
$(call go-get-tool,$(GO_LICENSES),github.com/google/go-licenses@latest)

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
Expand All @@ -128,7 +146,7 @@ TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
5 changes: 5 additions & 0 deletions hack/licenses.md.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Dependency Licenses

{{ range . }}
- {{.Name}}@{{.Version}} ([{{.LicenseName}}]({{.LicenseURL}}))
{{- end }}