This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add pre-release and release workflows, restructure CI test/bui…
…ld steps (#222) * chore: Added pre-release workflow, restructure ci and build Signed-off-by: Christian Kreuzberger <[email protected]> * chore: added .versionrc Signed-off-by: Christian Kreuzberger <[email protected]> * Update go mod Signed-off-by: Christian Kreuzberger <[email protected]> * chore: added helm-chart build Signed-off-by: Christian Kreuzberger <[email protected]> * Added release workflow Signed-off-by: Christian Kreuzberger <[email protected]> * review: use proper release pipeline Signed-off-by: Christian Kreuzberger <[email protected]> * Move helm charts to chart directory Signed-off-by: Christian Kreuzberger <[email protected]> * Move release notes into CHANGELOG.md in accordance with the release pipeline Signed-off-by: Christian Kreuzberger <[email protected]> * Changes according to review Signed-off-by: Christian Kreuzberger <[email protected]>
- Loading branch information
1 parent
b86311d
commit 34823fa
Showing
42 changed files
with
455 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ README.md | |
skaffold.yaml | ||
reviewdog.yml | ||
charts/ | ||
deploy/ | ||
deploy/ | ||
.github/ | ||
installer/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: 'Docker Build Push' | ||
description: 'Docker build and Push' | ||
inputs: | ||
TAGS: | ||
description: "List of tags to be pushed, e.g., keptncontrib/my-service:1.2.3" | ||
required: true | ||
VERSION: | ||
description: "Version/Tag that the image should be published with" | ||
required: true | ||
REGISTRY_USER: | ||
default: '' | ||
REGISTRY_PASSWORD: | ||
default: '' | ||
GITHUB_TOKEN: | ||
default: '' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
if: ${{ inputs.REGISTRY_USER != '' }} | ||
with: | ||
username: ${{ inputs.REGISTRY_USER }} | ||
password: ${{ inputs.REGISTRY_PASSWORD }} | ||
|
||
- name: Login to GitHub Container Registry | ||
if: ${{ inputs.GITHUB_TOKEN != '' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ inputs.GITHUB_TOKEN }} | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- id: docker_build_image | ||
name: "Docker Build" | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
tags: ${{ inputs.TAGS }} | ||
build-args: | | ||
version=${{ inputs.VERSION }} | ||
push: true | ||
pull: true # do we need this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: 'Unit Tests' | ||
description: 'Run unit tests using go' | ||
inputs: | ||
GO_VERSION: | ||
default: "1.16" | ||
env: | ||
GO111MODULE: "on" | ||
GOPROXY: "https://proxy.golang.org" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: ${{ inputs.GO_VERSION }} | ||
- name: Test | ||
shell: bash | ||
run: go test -race -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,18 +90,28 @@ jobs: | |
echo "::set-output name=TIME::$(date +'%H%M')" | ||
echo "::set-output name=DATETIME::$(date +'%Y%m%d')$(date +'%H%M')" | ||
#### | ||
# unit tests | ||
#### | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
############################################################################ | ||
# Unit tests # | ||
# Build Docker Image # | ||
############################################################################ | ||
unit-tests: | ||
name: Unit Tests | ||
needs: prepare_ci_run | ||
docker_build: | ||
needs: [prepare_ci_run] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} | ||
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
|
@@ -111,23 +121,24 @@ jobs: | |
with: | ||
env-file: .ci_env | ||
|
||
- name: Test | ||
run: go test -coverprofile=coverage.txt -covermode=atomic -v ./... | ||
working-directory: . | ||
- name: Docker Build | ||
uses: ./.github/actions/docker-build | ||
with: | ||
TAGS: | | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}.${{ env.DATETIME }} | ||
VERSION: ${{ env.VERSION }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
|
||
############################################################################ | ||
# Build Docker Image # | ||
############################################################################ | ||
docker_build: | ||
needs: [prepare_ci_run, unit-tests] | ||
name: Docker Build | ||
helm_chart_build: | ||
needs: [prepare_ci_run, docker_build] | ||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} | ||
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} | ||
DATETIME: ${{ needs.prepare_ci_run.outputs.DATE }}${{ needs.prepare_ci_run.outputs.TIME }} | ||
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | ||
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
@@ -138,40 +149,13 @@ jobs: | |
with: | ||
env-file: .ci_env | ||
|
||
- id: docker_login | ||
name: Docker Login | ||
# only run docker login on pushes; also for PRs, but only if this is not a fork | ||
if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository) | ||
# note: GH does not allow to access secrets for PRs from a forked repositories due to security reasons | ||
# that's fine, but it means we can't push images to dockerhub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.REGISTRY_USER }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}.${DATETIME}" "${IMAGE}" | ||
|
||
- id: docker_build | ||
name: Docker Build | ||
uses: keptn/gh-action-build-docker-image@master | ||
with: | ||
VERSION: ${{ env.VERSION }} | ||
IMAGE_NAME: "${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}" | ||
DATETIME: ${{ env.DATETIME }} | ||
|
||
- id: create_docker_build_report | ||
name: Create Docker Build Report | ||
run: | | ||
echo "The following Docker Images have been built: " > docker_build_report_final.txt | ||
cat docker_build_report.txt >> docker_build_report_final.txt || echo "* No images have been built or uploaded" >> docker_build_report_final.txt | ||
echo "---" | ||
cat docker_build_report_final.txt | ||
- id: report_docker_build_to_pr | ||
# Comment the docker build report to the PR | ||
# This only works for PRs coming from inside of the repo, not from forks | ||
name: Report Docker Build to PR | ||
if: (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.repository) | ||
uses: marocchino/[email protected] | ||
- name: Upload Helm Chart as an artifact | ||
id: upload_helm_chart | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
path: docker_build_report_final.txt | ||
recreate: true | ||
name: helm-charts | ||
path: installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Create Pre-Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
pre-release: | ||
needs: test | ||
name: Pre-Release | ||
uses: keptn/gh-automation/.github/workflows/[email protected] | ||
|
||
docker_build: | ||
needs: [pre-release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: ./.github/actions/docker-build | ||
with: | ||
TAGS: | | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
VERSION: ${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
helm_chart_build: | ||
needs: [pre-release, docker_build] | ||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Create Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
release: | ||
needs: test | ||
name: Release | ||
uses: keptn/gh-automation/.github/workflows/[email protected] | ||
|
||
docker_build: | ||
needs: [release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: ./.github/actions/docker-build | ||
with: | ||
TAGS: | | ||
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
VERSION: ${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | ||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
helm_chart_build: | ||
needs: [release, docker_build] | ||
|
||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Unit Tests | ||
on: | ||
workflow_dispatch: # run CI when triggered manually | ||
workflow_call: # run when called from another workflow | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,6 @@ remediation.yaml | |
|
||
/.idea | ||
/*.iml | ||
|
||
# ignore installer folder (packaged helm chart) | ||
installer/ |
Oops, something went wrong.