-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from stakater/feature/add-tekton-workflows
add tekton workflows
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 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,61 @@ | ||
name: Pull Request | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
HELM_PACKAGE_NAME: | ||
description: name for helm package | ||
required: true | ||
type: string | ||
secrets: | ||
CONTAINER_REGISTRY_URL: | ||
description: "Container registry to publish docker image" | ||
required: true | ||
CONTAINER_REGISTRY_USERNAME: | ||
description: "Username to login to container registry" | ||
required: true | ||
CONTAINER_REGISTRY_PASSWORD: | ||
description: "Password to login to container registry" | ||
required: true | ||
|
||
jobs: | ||
package-and-push-helm-chart: | ||
name: Package and Push Helm Chart | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Generate Tag | ||
id: generate_tag | ||
run: | | ||
sha=${{ github.event.pull_request.head.sha }} | ||
tag="snapshot-pr-${{ github.event.pull_request.number }}-${sha:0:8}" | ||
echo "GIT_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT | ||
# Set up helm binary | ||
- name: Set up Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: v3.8.2 | ||
|
||
- name: Login to Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ secrets.CONTAINER_REGISTRY_URL }} | ||
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} | ||
|
||
- name: Test and Package Helm Chart | ||
run: | | ||
sed -i "s/^version:.*/version: ${{ steps.generate_tag.outputs.GIT_TAG }}/" helm/Chart.yaml | ||
helm lint helm/ | ||
helm -n test template ${{ inputs.HELM_PACKAGE_NAME }} helm/ | ||
helm package helm/ | ||
- name: Push Helm Chart to Registry | ||
run: | | ||
helm push ${{ inputs.HELM_PACKAGE_NAME }}-${{ steps.generate_tag.outputs.GIT_TAG }}.tgz oci://ghcr.io/stakater/charts |
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,91 @@ | ||
name: Push | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
HELM_PACKAGE_NAME: | ||
description: name for helm package | ||
required: true | ||
type: string | ||
secrets: | ||
GH_TOKEN: | ||
description: "GitHub token" | ||
required: true | ||
CONTAINER_REGISTRY_URL: | ||
description: "Container registry to publish docker image" | ||
required: true | ||
CONTAINER_REGISTRY_USERNAME: | ||
description: "Username to login to container registry" | ||
required: true | ||
CONTAINER_REGISTRY_PASSWORD: | ||
description: "Password to login to container registry" | ||
required: true | ||
|
||
jobs: | ||
package-and-push-helm-chart: | ||
name: Package and Push Helm Chart | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' | ||
|
||
- name: Generate Tag | ||
id: generate_tag | ||
uses: anothrNick/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
WITH_V: false | ||
DEFAULT_BUMP: patch | ||
RELEASE_BRANCHES: main | ||
DRY_RUN: true | ||
|
||
# Set up helm binary | ||
- name: Set up Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: v3.8.2 | ||
|
||
- name: Login to Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ secrets.CONTAINER_REGISTRY_URL }} | ||
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} | ||
|
||
- name: Test and Package Helm Chart | ||
run: | | ||
sed -i "s/^version:.*/version: ${{ steps.generate_tag.outputs.new_tag }}/" helm/Chart.yaml | ||
helm lint helm/ | ||
helm -n test template $inputs.HELM_PACKAGE_NAME helm/ | ||
helm package helm/ | ||
- name: Push Helm Chart to Registry | ||
run: | | ||
helm push $inputs.HELM_PACKAGE_NAME-${{ steps.generate_tag.outputs.new_tag }}.tgz oci://ghcr.io/stakater/charts | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ steps.generate_tag.outputs.new_tag }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Render Helm Chart | ||
run: | | ||
helm template $inputs.HELM_PACKAGE_NAME helm > task/$inputs.HELM_PACKAGE_NAME/$inputs.HELM_PACKAGE_NAME.yaml | ||
- name: Commit Changes | ||
run: | | ||
git pull --quiet origin main || true | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "stakater-user" | ||
git add task/$inputs.HELM_PACKAGE_NAME/$inputs.HELM_PACKAGE_NAME.yaml | ||
git commit -m "[skip ci] Add rendered and modified Helm chart" | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GH_TOKEN }} | ||
branch: ${{ github.ref }} |