Skip to content

Commit

Permalink
Merge pull request #82 from stakater/feature/add-tekton-workflows
Browse files Browse the repository at this point in the history
add tekton workflows
  • Loading branch information
fabian-heib authored Dec 19, 2023
2 parents 51262cd + ea0aa97 commit 1a37203
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/pull_request_tekton.yaml
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
91 changes: 91 additions & 0 deletions .github/workflows/push_tekton.yaml
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 }}

0 comments on commit 1a37203

Please sign in to comment.