pipeline: Adding PR generation to helm #41
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
name: Container Images | |
# todo - make this a creusable workflow, where caller call it with | |
# workflow_id and workflow_version where the reources path is ./$workflow_id | |
# from the context | |
on: | |
workflow_call: | |
inputs: | |
workflow_id: | |
required: true | |
type: string | |
workflow_version: | |
required: true | |
type: string | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
env: | |
workflow_id: mta | |
workflow_version: "0.0.1" | |
KN_VERSION: "v1.11.0" | |
KN_WORKFLOW_VERSION: "0.32.0" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Buildah Action | |
id: build-image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
image: serverless-workflow-${{ env.workflow_id }} | |
tags: latest ${{ github.sha }} | |
extra-args: --ulimit nofile=4096:4096 | |
containerfiles: | | |
pipeline/workflow-builder.Dockerfile | |
build-args: | | |
WF_RESOURCES=${{ env.workflow_id }}/ | |
- name: Push To quay.io | |
id: push-to-quay | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ steps.build-image.outputs.image }} | |
tags: ${{ steps.build-image.outputs.tags }} | |
registry: quay.io/orchestrator | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Print image url | |
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" | |
generate-manifests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup kn-workflow | |
run: curl -L https://github.com/rgolangh/kie-tools/releases/download/0.0.0-fix-kn-workflow/kn-workflow -o kn-workflow && chmod +x kn-workflow | |
- name: kn-workflow | |
run: cd ${{ env.workflow_id }} && ../kn-workflow gen-manifest | |
- name: Download yq | |
run: curl -L https://github.com/mikefarah/yq/releases/download/v4.35.2/yq_linux_x86_64 -o yq | |
- name: Remove dev profile | |
run: yq -i 'del(.metadata.annotations."sonataflow.org/profile")' ${{ env.workflow_id }}/manifests/01-sonataflow*.yaml | |
- name: Set container image ref in SonataFlow resource | |
run: yq -i '.spec.podTemplate.container.image="quay.io/orchestrator/serverless-workflow-${{ env.workflow_id }}:${{ github.sha }}"' ${{ env.workflow_id }}/manifests/01-sonataflow*.yaml | |
- name: Archive manifests | |
uses: actions/upload-artifact@v3 | |
with: | |
name: serverless-workflow-${{ env.workflow_id }} | |
path: ${{ env.workflow_id }}/manifests | |
- name: Send PRs to helm repo | |
run: | | |
gh repo clone rgolangh/serverless-workflows-helm | |
cd serverless-workflows-helm | |
git switch -c ${{ github.ref_name }} | |
cp ../${{ env.workflow_id }}/manifests/* charts/workflows/charts/${{ env.workflow_id }}/templates | |
git add -A | |
git commit -m "Automated PR from ${{ env.workflow_id }} pipeline" | |
git push origin HEAD | |
gh pr create --title "Automatic manifests generation from ${{ github.ref_name }}" \ | |
--label "automated pr" \ | |
--body " | |
## Type of change | |
- [X] Updating manifests | |
" |