-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Pelletier
committed
Feb 2, 2024
1 parent
907111f
commit 15ef67f
Showing
13 changed files
with
313 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Github Actions | ||
This monorepo consists of 3 artifacts that are versioned, built, and released separately. | ||
- minimal-app | ||
- operator | ||
- operator/webhook | ||
|
||
## PR builds | ||
When a PR is opened or updated, it will determine if any files changed in each of the sub-project directories. | ||
If a file has changed it will trigger a build for that sub-project which runs a number of checks. | ||
|
||
## Releasing | ||
Release builds are triggered when code is merged to the main branch. | ||
It will also listen to each subdirectory and run the respective release job for each sub-project if any changes were found. | ||
|
||
To perform a new release, simply update the version for a given subproject. | ||
The version can be found either in a version.txt file or pom.xml file at the root of each subproject. | ||
New releases of the same version will never overwrite old releases. | ||
If the intent is to overwrite an old github release or docker image package, then the old artifact and its associated git tags should be deleted first. | ||
If a previous attempt at release failed, it can be re-ran by going to the github actions tab, choose the job that failed, click re-run on the top right. | ||
|
||
## Caching | ||
There is currently no caching for builds, but it could be added at a later date. |
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,93 @@ | ||
name: minimal-app-workflow | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- minimal-app/** | ||
- .github/workflows/minimal-app.yml | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- operator/** | ||
- "!operator/webhook/**" | ||
- .github/workflows/operator.yml | ||
|
||
env: | ||
WORKING_DIR: ./minimal-app | ||
REGISTRY: ghcr.io/octoconsulting | ||
IMAGE_NAME: keip/minimal-app | ||
JAVA_VERSION: 17 | ||
GIT_TAG_PREFIX: minimal-app_v | ||
|
||
jobs: | ||
build: | ||
name: build image | ||
if: github.ref != 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: "${{ env.JAVA_VERSION }}" | ||
distribution: "temurin" | ||
- run: mvn --batch-mode --update-snapshots verify | ||
name: build image | ||
|
||
release: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
permissions: | ||
contents: write # create git tags | ||
packages: write # push docker images | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION" >> "$GITHUB_OUTPUT" | ||
cat $GITHUB_OUTPUT | ||
id: naming-selector | ||
name: generate names for artifacts | ||
- run: | | ||
! docker manifest inspect ${{ steps.naming-selector.outputs.IMAGE_NAME }} | ||
name: confirm image is not already pushed | ||
- run: | | ||
git fetch --tags | ||
! git rev-parse -q --verify "refs/tags/${{ steps.naming-selector.outputs.TAG_NAME }}" | ||
name: confirm git tag does not exist | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: "${{ env.JAVA_VERSION }}" | ||
distribution: "temurin" | ||
- run: mvn --batch-mode --update-snapshots verify | ||
name: build image | ||
|
||
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- run: docker push ${{ steps.naming-selector.outputs.IMAGE_NAME }} | ||
|
||
- uses: mathieudutour/github-tag-action@v6.1 | ||
id: tag_version | ||
with: | ||
custom_tag: ${{ steps.naming-selector.outputs.TAG_NAME }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# avoid v prefix before tag | ||
tag_prefix: "" |
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,74 @@ | ||
name: operator-workflow | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- operator/** | ||
- "!operator/webhook/**" | ||
- .github/workflows/operator.yml | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- operator/** | ||
- "!operator/webhook/**" | ||
- .github/workflows/operator.yml | ||
|
||
env: | ||
WORKING_DIR: ./operator | ||
GIT_TAG_PREFIX: operator_v | ||
|
||
jobs: | ||
build: | ||
if: github.ref != 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: make prep-release | ||
name: generate release files | ||
|
||
release: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- run: | | ||
VERSION=$(cat version.txt) | ||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT" | ||
cat $GITHUB_OUTPUT | ||
id: naming-selector | ||
name: generate names for artifacts | ||
- run: | | ||
git fetch --tags | ||
! git rev-parse -q --verify "refs/tags/${{ steps.naming-selector.outputs.TAG_NAME }}" | ||
name: confirm git tag does not exist | ||
- run: make prep-release | ||
name: generate release files | ||
|
||
- uses: mathieudutour/github-tag-action@v6.1 | ||
id: tag_version | ||
with: | ||
custom_tag: ${{ steps.naming-selector.outputs.TAG_NAME }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# avoid v prefix before tag | ||
tag_prefix: "" | ||
|
||
- uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ steps.tag_version.outputs.new_tag }} | ||
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
artifactErrorsFailBuild: true | ||
artifacts: ${{ env.WORKING_DIR }}/output/* |
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,104 @@ | ||
name: webhook-workflow | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- operator/webhook/** | ||
- .github/workflows/webhook.yml | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- operator/** | ||
- "!operator/webhook/**" | ||
- .github/workflows/operator.yml | ||
|
||
env: | ||
WORKING_DIR: ./operator/webhook | ||
REGISTRY: ghcr.io/octoconsulting | ||
IMAGE_NAME: keip/route-webhook | ||
GIT_TAG_PREFIX: webhook_v | ||
|
||
jobs: | ||
test: | ||
name: unit test | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- run: python3 -m pip install -r requirements.txt | ||
- run: python3 -m pip install -r requirements-dev.txt | ||
- run: make test | ||
|
||
build: | ||
name: build image | ||
needs: test | ||
if: github.ref != 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: ${{ env.WORKING_DIR }} | ||
push: false | ||
|
||
release: | ||
needs: test | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ env.WORKING_DIR }} | ||
permissions: | ||
contents: write # create git tags | ||
packages: write # push docker images | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
VERSION=$(cat version.txt) | ||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION" >> "$GITHUB_OUTPUT" | ||
cat $GITHUB_OUTPUT | ||
id: naming-selector | ||
name: generate names for artifacts | ||
- run: | | ||
! docker manifest inspect ${{ steps.naming-selector.outputs.IMAGE_NAME }} | ||
name: confirm image is not already pushed | ||
- run: | | ||
git fetch --tags | ||
! git rev-parse -q --verify "refs/tags/${{ steps.naming-selector.outputs.TAG_NAME }}" | ||
name: confirm git tag does not exist | ||
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
with: | ||
context: ${{ env.WORKING_DIR }} | ||
push: true | ||
tags: ${{ steps.naming-selector.outputs.IMAGE_NAME }} | ||
|
||
- uses: mathieudutour/github-tag-action@v6.1 | ||
id: tag_version | ||
with: | ||
custom_tag: ${{ steps.naming-selector.outputs.TAG_NAME }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# avoid v prefix before tag | ||
tag_prefix: "" |
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
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
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
File renamed without changes.
File renamed without changes.
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 @@ | ||
0.1.0 |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION ?= 0.4.0 | ||
VERSION := $(shell cat version.txt) | ||
HOST_PORT ?= 7080 | ||
|
||
IMG_REGISTRY := ghcr.io/octoconsulting | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mypy | ||
pytest | ||
httpx | ||
coverage | ||
mypy==1.8.0 | ||
pytest==8.0.0 | ||
httpx==0.26.0 | ||
coverage==7.4.1 |
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 @@ | ||
0.4.0 |