From b03b3f88cfb24825911eb0720aa1a5e0a351aa2c Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Mon, 26 Jan 2026 13:56:48 +0200 Subject: [PATCH 01/14] feat(bulk-import): add bulk-import rhdh workflow Signed-off-by: Oleksandr Andriienko --- workflows/bulk-import-git-repos/Makefile | 39 ++ workflows/bulk-import-git-repos/README.md | 28 + .../application.properties | 12 + .../create-pr-universal.sw.yaml | 294 ++++++++++ .../01-configmap_universal-pr-props.yaml | 18 + ...map_01-universal-pr-resources-schemas.yaml | 48 ++ ...igmap_02-universal-pr-resources-specs.yaml | 510 ++++++++++++++++++ .../manifests/04-sonataflow_universal-pr.yaml | 381 +++++++++++++ .../create-pr-universal-input-schema.json | 41 ++ .../bulk-import-git-repos/specs/github.yaml | 328 +++++++++++ .../bulk-import-git-repos/specs/gitlab.yaml | 174 ++++++ 11 files changed, 1873 insertions(+) create mode 100644 workflows/bulk-import-git-repos/Makefile create mode 100644 workflows/bulk-import-git-repos/README.md create mode 100644 workflows/bulk-import-git-repos/application.properties create mode 100644 workflows/bulk-import-git-repos/create-pr-universal.sw.yaml create mode 100755 workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml create mode 100755 workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml create mode 100755 workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml create mode 100755 workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml create mode 100644 workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json create mode 100644 workflows/bulk-import-git-repos/specs/github.yaml create mode 100644 workflows/bulk-import-git-repos/specs/gitlab.yaml diff --git a/workflows/bulk-import-git-repos/Makefile b/workflows/bulk-import-git-repos/Makefile new file mode 100644 index 00000000..17115796 --- /dev/null +++ b/workflows/bulk-import-git-repos/Makefile @@ -0,0 +1,39 @@ +# Makefile for bulk-import-git-repos workflow +# Generates Kubernetes manifests locally + +WORKFLOW_ID := bulk-import-git-repos +WORKFLOW_IMAGE_REGISTRY ?= quay.io +WORKFLOW_IMAGE_NAMESPACE ?= orchestrator +WORKFLOW_IMAGE_REPO ?= serverless-workflow-$(WORKFLOW_ID) +WORKFLOW_IMAGE_TAG ?= latest +CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker) +LINUX_IMAGE ?= quay.io/orchestrator/ubi9-pipeline:latest + +.PHONY: gen-manifests clean help + +help: + @echo "Available targets:" + @echo " gen-manifests - Generate Kubernetes manifests" + @echo " clean - Remove generated manifests" + @echo "" + @echo "Variables:" + @echo " WORKFLOW_IMAGE_TAG - Image tag (default: latest)" + @echo " CONTAINER_ENGINE - docker or podman (default: auto-detect)" + +gen-manifests: + @echo "๐Ÿ› ๏ธ Generating manifests for $(WORKFLOW_ID)..." + @echo -e "\nkie.flyway.enabled=true" >> application.properties + @$(CONTAINER_ENGINE) run --rm \ + -v $(PWD):/workdir:Z \ + -w /workdir \ + $(LINUX_IMAGE) \ + kn-workflow gen-manifest \ + --profile=gitops \ + --namespace='' \ + --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG) + @echo "โœ… Manifests generated in ./manifests/" + +clean: + @echo "๐Ÿงน Cleaning generated manifests..." + @rm -rf manifests/ + @echo "โœ… Cleaned" diff --git a/workflows/bulk-import-git-repos/README.md b/workflows/bulk-import-git-repos/README.md new file mode 100644 index 00000000..32e26d71 --- /dev/null +++ b/workflows/bulk-import-git-repos/README.md @@ -0,0 +1,28 @@ +# Bulk Import Git Repos Workflow + +This workflow creates pull requests (GitHub) or merge requests (GitLab) based on the `approvalTool` parameter. + +## Overview + +The workflow supports both GitHub and GitLab repositories and can create PRs/MRs with multiple files. + +## Input Schema + +The workflow expects the following input parameters: +- `approvalTool`: Either "GIT" for GitHub or "GITLAB" for GitLab +- `owner`: The owner/namespace of the repository +- `repo`: The repository name +- `baseBranch`: The base branch to create the PR/MR from +- `targetBranch`: The target branch name for the PR/MR + +## Workflow Steps + +1. **GetScafolderData**: Retrieves mock data with files to be added +2. **RouteToProvider**: Routes to either GitHub or GitLab workflow based on `approvalTool` +3. **GitHub Flow**: Creates branch, commits files, and creates a pull request +4. **GitLab Flow**: Searches for project, creates branch, commits files, and creates a merge request + +## Output + +- For GitHub: Returns PR URL in `PR_URL` output +- For GitLab: Returns MR URL in `MR_URL` output diff --git a/workflows/bulk-import-git-repos/application.properties b/workflows/bulk-import-git-repos/application.properties new file mode 100644 index 00000000..720ee6a2 --- /dev/null +++ b/workflows/bulk-import-git-repos/application.properties @@ -0,0 +1,12 @@ +# This property is used to select the log level, which controls the amount +# of information logged on HTTP requests based on the severity of the events. +# Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. +# and see https://quarkus.io/guides/logging for documentation +quarkus.log.category."org.apache.http".level=INFO +quarkus.log.level=INFO + +kie.flyway.enabled=true +-e +kie.flyway.enabled=true +-e +kie.flyway.enabled=true diff --git a/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml b/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml new file mode 100644 index 00000000..a28ab86b --- /dev/null +++ b/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml @@ -0,0 +1,294 @@ +id: universal-pr +version: "1.0" +specVersion: "0.8" +name: "Create Universal Pull/Merge Request" +description: "This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter." +dataInputSchema: schemas/create-pr-universal-input-schema.json +functions: + # Common functions + - name: scafolderMock + type: expression + operation: | + { + "files": [ + { + "path": "README.md", + "content": "# Hello World" + }, + { + "path": "index.js", + "content": "console.log('Hello, world!');" + } + ] + } + - name: sysLog + type: custom + operation: sysout:INFO + + # GitHub functions + - name: getBranchSHA + operation: specs/github.yaml#getBranchSHA + - name: pushCommitBranch + operation: specs/github.yaml#updateBranchRef + - name: createCommit + operation: specs/github.yaml#createCommit + - name: createTree + operation: specs/github.yaml#createTree + - name: createBlob + operation: specs/github.yaml#createBlob + - name: createBranch + operation: specs/github.yaml#createBranch + - name: getCommitDetails + operation: specs/github.yaml#getCommitDetails + - name: createPullRequest + operation: specs/github.yaml#createPullRequest + - name: createNewBlob + type: expression + operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' + - name: githubSuccessResult + type: expression + operation: '{ + "result": { + "message": "PR created", + "outputs":[ + { + "key": "PR_URL", + "value": .prURL.html_url, + "format":"link" + } + ] + } + }' + + # GitLab functions + - name: searchProjects + operation: specs/gitlab.yaml#searchProjects + - name: getProject + operation: specs/gitlab.yaml#getProject + - name: gitlabCreateBranch + operation: specs/gitlab.yaml#createBranch + - name: gitlabCreateCommit + operation: specs/gitlab.yaml#createCommit + - name: gitlabCreateMergeRequest + operation: specs/gitlab.yaml#createMergeRequest + - name: gitlabSuccessResult + type: expression + operation: '{ + "result": { + "message": "Merge Request created", + "outputs":[ + { + "key": "MR_URL", + "value": .mrURL.web_url, + "format":"link" + } + ] + } + }' + +start: "GetScafolderData" +states: + - name: GetScafolderData + type: operation + actions: + - name: "Get Scafolder data" + functionRef: + refName: scafolderMock + actionDataFilter: + toStateData: .scafolderReponse + transition: RouteToProvider + + - name: RouteToProvider + type: switch + dataConditions: + - condition: '${ .approvalTool == "GIT" }' + transition: GitHubCreateBranch + - condition: '${ .approvalTool == "GITLAB" }' + transition: GitLabSearchProject + defaultCondition: + transition: ErrorUnknownProvider + + - name: ErrorUnknownProvider + type: inject + data: + error: "Unknown or unsupported approval tool" + approvalTool: "${ .approvalTool }" + end: true + + # GitHub workflow states + - name: GitHubCreateBranch + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) }' + - name: "GetHeadSha" + functionRef: + refName: getBranchSHA + arguments: + owner: .owner + repo: .repo + ref: '"heads/" + .baseBranch' + actionDataFilter: + toStateData: .latestSHA + - name: "createBranch" + functionRef: + refName: createBranch + arguments: + owner: .owner + repo: .repo + ref: '"refs/heads/" + .targetBranch' + sha: .latestSHA.object.sha + - name: "getCommitDetails" + functionRef: + refName: getCommitDetails + arguments: + owner: .owner + repo: .repo + commit_sha: .latestSHA.object.sha + actionDataFilter: + toStateData: .commit + transition: GitHubCreateFiles + + - name: GitHubCreateFiles + type: foreach + inputCollection: "${ [.scafolderReponse.files[]] }" + iterationParam: currentFile + outputCollection: .blobs + actions: + - name: "createBlob" + functionRef: + refName: createBlob + arguments: + owner: .owner + repo: .repo + content: ($currentFile.content|tostring) + encoding: "utf-8" + - name: createNewBlob + functionRef: + refName: createNewBlob + transition: GitHubCreateNewTree + + - name: GitHubCreateNewTree + type: operation + actions: + - name: "createTree" + functionRef: + refName: createTree + arguments: + owner: .owner + repo: .repo + base_tree: .commit.tree.sha + tree: .blobs + actionDataFilter: + toStateData: .newTree + - name: "createCommit" + functionRef: + refName: createCommit + arguments: + owner: .owner + repo: .repo + message: "Added/Updated multiple files via API" + tree: .newTree.sha + parents: [.latestSHA.object.sha] + actionDataFilter: + toStateData: .newCommit + - name: "push" + functionRef: + refName: pushCommitBranch + arguments: + owner: .owner + repo: .repo + ref: '"heads/" + .targetBranch' + sha: .newCommit.sha + force: false + transition: GitHubCreatePR + + - name: GitHubCreatePR + type: operation + actions: + - name: "createPullRequest" + functionRef: + refName: createPullRequest + arguments: + owner: .owner + repo: .repo + title: "Automated PR" + body: "" + head: .targetBranch + base: .baseBranch + actionDataFilter: + toStateData: .prURL + - name: setOutput + functionRef: + refName: githubSuccessResult + end: true + + # GitLab workflow states + - name: GitLabSearchProject + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' + - name: SearchProjects + functionRef: + refName: searchProjects + arguments: + search: .repo + membership: true + per_page: 100 + actionDataFilter: + toStateData: .projectsList + stateDataFilter: + output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' + transition: GitLabCreateBranch + + - name: GitLabCreateBranch + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' + - name: "createBranch" + functionRef: + refName: gitlabCreateBranch + arguments: + id: .project.id | tostring + branch: .targetBranch + ref: .baseBranch + transition: GitLabCreateCommit + + - name: GitLabCreateCommit + type: operation + actions: + - name: "createCommit" + functionRef: + refName: gitlabCreateCommit + arguments: + id: .project.id | tostring + branch: .targetBranch + commit_message: "Added/Updated multiple files via API" + actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' + transition: GitLabCreateMR + + - name: GitLabCreateMR + type: operation + actions: + - name: "createMergeRequest" + functionRef: + refName: gitlabCreateMergeRequest + arguments: + id: .project.id | tostring + source_branch: .targetBranch + target_branch: .baseBranch + title: "Automated MR" + actionDataFilter: + toStateData: .mrURL + - name: setOutput + functionRef: + refName: gitlabSuccessResult + end: true diff --git a/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml b/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml new file mode 100755 index 00000000..4aac555f --- /dev/null +++ b/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +data: + application.properties: "# This property is used to select the log level, which + controls the amount\n# of information logged on HTTP requests based on the severity + of the events.\n# Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL.\n# + and see https://quarkus.io/guides/logging for documentation\nquarkus.log.category.\"org.apache.http\".level=INFO\nquarkus.log.level=INFO\n\nkie.flyway.enabled=true\n-e + \nkie.flyway.enabled=true\n-e \nkie.flyway.enabled=true\n" +kind: ConfigMap +metadata: + creationTimestamp: null + labels: + app: universal-pr + app.kubernetes.io/component: serverless-workflow + app.kubernetes.io/managed-by: sonataflow-operator + app.kubernetes.io/name: universal-pr + sonataflow.org/workflow-app: universal-pr + sonataflow.org/workflow-namespace: "" + name: universal-pr-props diff --git a/workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml b/workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml new file mode 100755 index 00000000..e1bc69b9 --- /dev/null +++ b/workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml @@ -0,0 +1,48 @@ +apiVersion: v1 +data: + create-pr-universal-input-schema.json: | + { + "$id": "classpath:/schemas/create-pr-universal-input-schema.json", + "title": "Create Universal PR/MR Input Schema", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "approvalTool": { + "title": "Approval Tool", + "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", + "type": "string", + "enum": ["GIT", "GITLAB"] + }, + "owner": { + "title": "Owner", + "description": "The owner/namespace of the repository", + "type": "string" + }, + "repo": { + "title": "Repository", + "description": "The repository name", + "type": "string" + }, + "baseBranch": { + "title": "Base Branch", + "description": "The base branch to create the PR/MR from", + "type": "string" + }, + "targetBranch": { + "title": "Target Branch", + "description": "The target branch name for the PR/MR", + "type": "string" + } + }, + "required": [ + "approvalTool", + "owner", + "repo", + "baseBranch", + "targetBranch" + ] + } +kind: ConfigMap +metadata: + creationTimestamp: null + name: 01-universal-pr-resources-schemas diff --git a/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml b/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml new file mode 100755 index 00000000..fd76282d --- /dev/null +++ b/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml @@ -0,0 +1,510 @@ +apiVersion: v1 +data: + github.yaml: | + openapi: 3.0.0 + info: + title: GitHub Repository Automation API + version: 1.0.0 + description: API specification for automating GitHub repository tasks using the GitHub REST API v3. + + servers: + - url: https://api.github.com + description: GitHub API + security: + - BearerToken: [] + paths: + /repos/{owner}/{repo}/git/ref/{ref}: + get: + summary: Get the SHA of a ref + operationId: getBranchSHA + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved branch reference + content: + application/json: + schema: + type: object + properties: + object: + type: object + properties: + sha: + type: string + '404': + description: Branch not found + /repos/{owner}/{repo}/git/refs: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + ref: + type: string + sha: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/refs/{ref}: + patch: + summary: Update a branch reference + operationId: updateBranchRef + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + sha: + type: string + force: + type: boolean + responses: + '200': + description: Branch updated successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/blobs: + post: + summary: Create a new blob + operationId: createBlob + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + content: + type: string + encoding: + type: string + responses: + '201': + description: Blob created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/trees: + post: + summary: Create a new tree + operationId: createTree + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + base_tree: + type: string + tree: + type: array + items: + type: object + properties: + path: + type: string + mode: + type: string + type: + type: string + sha: + type: string + responses: + '201': + description: Tree created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + message: + type: string + tree: + type: string + parents: + type: array + items: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/commits/{commit_sha}: + get: + summary: Get details of a commit + operationId: getCommitDetails + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: commit_sha + in: path + required: true + schema: + type: string + responses: + '200': + description: Commit details retrieved successfully + content: + application/json: + schema: + type: object + properties: + tree: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/pulls: + post: + summary: Create a pull request + description: Opens a new pull request from a branch to the base branch. + operationId: createPullRequest + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + title: + type: string + example: "New Feature: Added new file" + body: + type: string + example: "This PR adds a new file using the GitHub REST API." + head: + type: string + example: "new-feature-branch" + base: + type: string + example: "main" + responses: + '201': + description: Pull request created successfully. + content: + application/json: + schema: + type: object + properties: + html_url: + type: string + example: "https://github.com/user/repo/pull/42" + '422': + description: Invalid input or pull request already exists. + components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication + gitlab.yaml: | + openapi: 3.0.0 + info: + title: GitLab Repository Automation API + version: 1.0.0 + description: API specification for automating GitLab repository tasks using the GitLab REST API v4. + + servers: + - url: https://gitlab.com/api/v4 + description: GitLab API + security: + - BearerToken: [] + paths: + /projects: + get: + summary: Search for projects + operationId: searchProjects + parameters: + - name: search + in: query + required: false + schema: + type: string + - name: membership + in: query + required: false + schema: + type: boolean + - name: per_page + in: query + required: false + schema: + type: integer + responses: + '200': + description: Successfully retrieved projects + content: + application/json: + schema: + type: array + items: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}: + get: + summary: Get project details + operationId: getProject + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved project + content: + application/json: + schema: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}/repository/branches: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + ref: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /projects/{id}/repository/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + commit_message: + type: string + actions: + type: array + items: + type: object + properties: + action: + type: string + file_path: + type: string + content: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /projects/{id}/merge_requests: + post: + summary: Create a merge request + operationId: createMergeRequest + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + source_branch: + type: string + target_branch: + type: string + title: + type: string + responses: + '201': + description: Merge request created successfully + content: + application/json: + schema: + type: object + properties: + web_url: + type: string + components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication +kind: ConfigMap +metadata: + creationTimestamp: null + name: 02-universal-pr-resources-specs diff --git a/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml new file mode 100755 index 00000000..b7dcefea --- /dev/null +++ b/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml @@ -0,0 +1,381 @@ +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + annotations: + sonataflow.org/description: This workflow creates a pull request (GitHub) or merge + request (GitLab) based on approvalTool parameter. + sonataflow.org/expressionLang: jq + sonataflow.org/profile: gitops + sonataflow.org/version: "1.0" + creationTimestamp: null + labels: + app: universal-pr + app.kubernetes.io/component: serverless-workflow + app.kubernetes.io/managed-by: sonataflow-operator + app.kubernetes.io/name: universal-pr + sonataflow.org/workflow-app: universal-pr + sonataflow.org/workflow-namespace: "" + name: universal-pr +spec: + flow: + dataInputSchema: + failOnValidationErrors: true + schema: schemas/create-pr-universal-input-schema.json + functions: + - name: scafolderMock + operation: | + { + "files": [ + { + "path": "README.md", + "content": "# Hello World" + }, + { + "path": "index.js", + "content": "console.log('Hello, world!');" + } + ] + } + type: expression + - name: sysLog + operation: sysout:INFO + type: custom + - name: getBranchSHA + operation: specs/github.yaml#getBranchSHA + type: rest + - name: pushCommitBranch + operation: specs/github.yaml#updateBranchRef + type: rest + - name: createCommit + operation: specs/github.yaml#createCommit + type: rest + - name: createTree + operation: specs/github.yaml#createTree + type: rest + - name: createBlob + operation: specs/github.yaml#createBlob + type: rest + - name: createBranch + operation: specs/github.yaml#createBranch + type: rest + - name: getCommitDetails + operation: specs/github.yaml#getCommitDetails + type: rest + - name: createPullRequest + operation: specs/github.yaml#createPullRequest + type: rest + - name: createNewBlob + operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": + "blob", "sha": $WORKFLOW.prevActionResult.sha}' + type: expression + - name: githubSuccessResult + operation: '{ "result": { "message": "PR created", "outputs":[ { "key": "PR_URL", + "value": .prURL.html_url, "format":"link" } ] } }' + type: expression + - name: searchProjects + operation: specs/gitlab.yaml#searchProjects + type: rest + - name: getProject + operation: specs/gitlab.yaml#getProject + type: rest + - name: gitlabCreateBranch + operation: specs/gitlab.yaml#createBranch + type: rest + - name: gitlabCreateCommit + operation: specs/gitlab.yaml#createCommit + type: rest + - name: gitlabCreateMergeRequest + operation: specs/gitlab.yaml#createMergeRequest + type: rest + - name: gitlabSuccessResult + operation: '{ "result": { "message": "Merge Request created", "outputs":[ { + "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }' + type: expression + start: + stateName: GetScafolderData + states: + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .scafolderReponse + useResults: true + functionRef: + invoke: sync + refName: scafolderMock + name: Get Scafolder data + name: GetScafolderData + transition: + nextState: RouteToProvider + type: operation + - dataConditions: + - condition: ${ .approvalTool == "GIT" } + transition: + nextState: GitHubCreateBranch + - condition: ${ .approvalTool == "GITLAB" } + transition: + nextState: GitLabSearchProject + defaultCondition: + transition: + nextState: ErrorUnknownProvider + name: RouteToProvider + type: switch + - data: + approvalTool: ${ .approvalTool } + error: Unknown or unsupported approval tool + end: + terminate: true + name: ErrorUnknownProvider + type: inject + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: ${ "Creating GitHub branch for " + (.owner | tostring) + "/" + + (.repo | tostring) } + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .latestSHA + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"heads/" + .baseBranch' + repo: .repo + invoke: sync + refName: getBranchSHA + name: GetHeadSha + - actionDataFilter: + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"refs/heads/" + .targetBranch' + repo: .repo + sha: .latestSHA.object.sha + invoke: sync + refName: createBranch + name: createBranch + - actionDataFilter: + toStateData: .commit + useResults: true + functionRef: + arguments: + commit_sha: .latestSHA.object.sha + owner: .owner + repo: .repo + invoke: sync + refName: getCommitDetails + name: getCommitDetails + name: GitHubCreateBranch + transition: + nextState: GitHubCreateFiles + type: operation + - actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + content: ($currentFile.content|tostring) + encoding: utf-8 + owner: .owner + repo: .repo + invoke: sync + refName: createBlob + name: createBlob + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: createNewBlob + name: createNewBlob + inputCollection: ${ [.scafolderReponse.files[]] } + iterationParam: currentFile + mode: parallel + name: GitHubCreateFiles + outputCollection: .blobs + transition: + nextState: GitHubCreateNewTree + type: foreach + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .newTree + useResults: true + functionRef: + arguments: + base_tree: .commit.tree.sha + owner: .owner + repo: .repo + tree: .blobs + invoke: sync + refName: createTree + name: createTree + - actionDataFilter: + toStateData: .newCommit + useResults: true + functionRef: + arguments: + message: Added/Updated multiple files via API + owner: .owner + parents: + - .latestSHA.object.sha + repo: .repo + tree: .newTree.sha + invoke: sync + refName: createCommit + name: createCommit + - actionDataFilter: + useResults: true + functionRef: + arguments: + force: false + owner: .owner + ref: '"heads/" + .targetBranch' + repo: .repo + sha: .newCommit.sha + invoke: sync + refName: pushCommitBranch + name: push + name: GitHubCreateNewTree + transition: + nextState: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .prURL + useResults: true + functionRef: + arguments: + base: .baseBranch + body: "" + head: .targetBranch + owner: .owner + repo: .repo + title: Automated PR + invoke: sync + refName: createPullRequest + name: createPullRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: githubSuccessResult + name: setOutput + end: + terminate: true + name: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + + (.repo | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .projectsList + useResults: true + functionRef: + arguments: + membership: true + per_page: 100 + search: .repo + invoke: sync + refName: searchProjects + name: SearchProjects + name: GitLabSearchProject + stateDataFilter: + output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace + == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: + $project} }' + transition: + nextState: GitLabCreateBranch + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Creating GitLab branch with project ID: " + (.project.id + | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + useResults: true + functionRef: + arguments: + branch: .targetBranch + id: .project.id | tostring + ref: .baseBranch + invoke: sync + refName: gitlabCreateBranch + name: createBranch + name: GitLabCreateBranch + transition: + nextState: GitLabCreateCommit + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": + .path, "content": .content }) }' + branch: .targetBranch + commit_message: Added/Updated multiple files via API + id: .project.id | tostring + invoke: sync + refName: gitlabCreateCommit + name: createCommit + name: GitLabCreateCommit + transition: + nextState: GitLabCreateMR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .mrURL + useResults: true + functionRef: + arguments: + id: .project.id | tostring + source_branch: .targetBranch + target_branch: .baseBranch + title: Automated MR + invoke: sync + refName: gitlabCreateMergeRequest + name: createMergeRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: gitlabSuccessResult + name: setOutput + end: + terminate: true + name: GitLabCreateMR + type: operation + podTemplate: + container: + image: quay.io/orchestrator/serverless-workflow-bulk-import-git-repos:latest + resources: {} + resources: + configMaps: + - configMap: + name: 01-universal-pr-resources-schemas + workflowPath: schemas + - configMap: + name: 02-universal-pr-resources-specs + workflowPath: specs +status: + address: {} + lastTimeRecoverAttempt: null diff --git a/workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json b/workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json new file mode 100644 index 00000000..93a0b5ac --- /dev/null +++ b/workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json @@ -0,0 +1,41 @@ +{ + "$id": "classpath:/schemas/create-pr-universal-input-schema.json", + "title": "Create Universal PR/MR Input Schema", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "approvalTool": { + "title": "Approval Tool", + "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", + "type": "string", + "enum": ["GIT", "GITLAB"] + }, + "owner": { + "title": "Owner", + "description": "The owner/namespace of the repository", + "type": "string" + }, + "repo": { + "title": "Repository", + "description": "The repository name", + "type": "string" + }, + "baseBranch": { + "title": "Base Branch", + "description": "The base branch to create the PR/MR from", + "type": "string" + }, + "targetBranch": { + "title": "Target Branch", + "description": "The target branch name for the PR/MR", + "type": "string" + } + }, + "required": [ + "approvalTool", + "owner", + "repo", + "baseBranch", + "targetBranch" + ] +} diff --git a/workflows/bulk-import-git-repos/specs/github.yaml b/workflows/bulk-import-git-repos/specs/github.yaml new file mode 100644 index 00000000..fa2b4839 --- /dev/null +++ b/workflows/bulk-import-git-repos/specs/github.yaml @@ -0,0 +1,328 @@ +openapi: 3.0.0 +info: + title: GitHub Repository Automation API + version: 1.0.0 + description: API specification for automating GitHub repository tasks using the GitHub REST API v3. + +servers: + - url: https://api.github.com + description: GitHub API +security: +- BearerToken: [] +paths: + /repos/{owner}/{repo}/git/ref/{ref}: + get: + summary: Get the SHA of a ref + operationId: getBranchSHA + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved branch reference + content: + application/json: + schema: + type: object + properties: + object: + type: object + properties: + sha: + type: string + '404': + description: Branch not found + /repos/{owner}/{repo}/git/refs: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + ref: + type: string + sha: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/refs/{ref}: + patch: + summary: Update a branch reference + operationId: updateBranchRef + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + sha: + type: string + force: + type: boolean + responses: + '200': + description: Branch updated successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/blobs: + post: + summary: Create a new blob + operationId: createBlob + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + content: + type: string + encoding: + type: string + responses: + '201': + description: Blob created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/trees: + post: + summary: Create a new tree + operationId: createTree + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + base_tree: + type: string + tree: + type: array + items: + type: object + properties: + path: + type: string + mode: + type: string + type: + type: string + sha: + type: string + responses: + '201': + description: Tree created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + message: + type: string + tree: + type: string + parents: + type: array + items: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/git/commits/{commit_sha}: + get: + summary: Get details of a commit + operationId: getCommitDetails + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: commit_sha + in: path + required: true + schema: + type: string + responses: + '200': + description: Commit details retrieved successfully + content: + application/json: + schema: + type: object + properties: + tree: + type: object + properties: + sha: + type: string + /repos/{owner}/{repo}/pulls: + post: + summary: Create a pull request + description: Opens a new pull request from a branch to the base branch. + operationId: createPullRequest + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + title: + type: string + example: "New Feature: Added new file" + body: + type: string + example: "This PR adds a new file using the GitHub REST API." + head: + type: string + example: "new-feature-branch" + base: + type: string + example: "main" + responses: + '201': + description: Pull request created successfully. + content: + application/json: + schema: + type: object + properties: + html_url: + type: string + example: "https://github.com/user/repo/pull/42" + '422': + description: Invalid input or pull request already exists. +components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication diff --git a/workflows/bulk-import-git-repos/specs/gitlab.yaml b/workflows/bulk-import-git-repos/specs/gitlab.yaml new file mode 100644 index 00000000..e620d77e --- /dev/null +++ b/workflows/bulk-import-git-repos/specs/gitlab.yaml @@ -0,0 +1,174 @@ +openapi: 3.0.0 +info: + title: GitLab Repository Automation API + version: 1.0.0 + description: API specification for automating GitLab repository tasks using the GitLab REST API v4. + +servers: + - url: https://gitlab.com/api/v4 + description: GitLab API +security: +- BearerToken: [] +paths: + /projects: + get: + summary: Search for projects + operationId: searchProjects + parameters: + - name: search + in: query + required: false + schema: + type: string + - name: membership + in: query + required: false + schema: + type: boolean + - name: per_page + in: query + required: false + schema: + type: integer + responses: + '200': + description: Successfully retrieved projects + content: + application/json: + schema: + type: array + items: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}: + get: + summary: Get project details + operationId: getProject + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved project + content: + application/json: + schema: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}/repository/branches: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + ref: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /projects/{id}/repository/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + commit_message: + type: string + actions: + type: array + items: + type: object + properties: + action: + type: string + file_path: + type: string + content: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /projects/{id}/merge_requests: + post: + summary: Create a merge request + operationId: createMergeRequest + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + source_branch: + type: string + target_branch: + type: string + title: + type: string + responses: + '201': + description: Merge request created successfully + content: + application/json: + schema: + type: object + properties: + web_url: + type: string +components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication From 7c4449be9ae88375217648bcd5b111f8e32de2be Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Mon, 26 Jan 2026 18:33:52 +0200 Subject: [PATCH 02/14] next changes Signed-off-by: Oleksandr Andriienko --- commands.env | 0 workflows/bulk-import-git-repos/Makefile | 6 +----- .../bulk-import-git-repos/application.properties | 16 +++++++++++----- workflows/bulk-import-git-repos/argfile.conf | 3 +++ 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 commands.env create mode 100644 workflows/bulk-import-git-repos/argfile.conf diff --git a/commands.env b/commands.env new file mode 100644 index 00000000..e69de29b diff --git a/workflows/bulk-import-git-repos/Makefile b/workflows/bulk-import-git-repos/Makefile index 17115796..98f50ff0 100644 --- a/workflows/bulk-import-git-repos/Makefile +++ b/workflows/bulk-import-git-repos/Makefile @@ -22,15 +22,11 @@ help: gen-manifests: @echo "๐Ÿ› ๏ธ Generating manifests for $(WORKFLOW_ID)..." - @echo -e "\nkie.flyway.enabled=true" >> application.properties @$(CONTAINER_ENGINE) run --rm \ -v $(PWD):/workdir:Z \ -w /workdir \ $(LINUX_IMAGE) \ - kn-workflow gen-manifest \ - --profile=gitops \ - --namespace='' \ - --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG) + /bin/bash -c "echo -e '\nkie.flyway.enabled=false' >> application.properties && kn-workflow gen-manifest --profile=gitops --namespace='' --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG)" @echo "โœ… Manifests generated in ./manifests/" clean: diff --git a/workflows/bulk-import-git-repos/application.properties b/workflows/bulk-import-git-repos/application.properties index 720ee6a2..304d1f2e 100644 --- a/workflows/bulk-import-git-repos/application.properties +++ b/workflows/bulk-import-git-repos/application.properties @@ -5,8 +5,14 @@ quarkus.log.category."org.apache.http".level=INFO quarkus.log.level=INFO -kie.flyway.enabled=true --e -kie.flyway.enabled=true --e -kie.flyway.enabled=true + +kie.flyway.enabled=false + +%dev.quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true +%dev.quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github + +%dev.quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true +%dev.quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two + +%dev.quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true +%dev.quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab diff --git a/workflows/bulk-import-git-repos/argfile.conf b/workflows/bulk-import-git-repos/argfile.conf new file mode 100644 index 00000000..dd7b939e --- /dev/null +++ b/workflows/bulk-import-git-repos/argfile.conf @@ -0,0 +1,3 @@ +FLOW_NAME=bulk-import-git-repos Serverless Workflow +FLOW_SUMMARY=bulk-import-git-repos Serverless Workflow +FLOW_DESCRIPTION=Workflow for creating pull requests (GitHub) or merge requests (GitLab) based on approvalTool parameter From ded6580b901420910e222f53812ea1436556f34c Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Sun, 22 Feb 2026 23:58:09 +0200 Subject: [PATCH 03/14] next changes Signed-off-by: Oleksandr Andriienko --- Makefile | 7 +- .../bulk-import-git-repos/Makefile | 35 ++ .../bulk-import-git-repos/README.md | 28 ++ .../bulk-import-git-repos/argfile.conf | 5 + .../bulk-import-git-repos/pom.xml | 200 +++++++++++ .../src/main/resources/application.properties | 31 ++ .../resources/create-pr-universal.sw.yaml | 284 ++++++++++++++++ .../create-pr-universal-input-schema.json | 41 +++ .../src/main/resources/specs/github.yaml | 312 ++++++++++++++++++ .../src/main/resources/specs/gitlab.yaml | 174 ++++++++++ .../manifests/00-secret_gh-pr-secrets.yaml | 3 +- .../manifests/04-sonataflow_gh-pr.yaml | 12 +- .../src/main/resources/application.properties | 4 +- 13 files changed, 1126 insertions(+), 10 deletions(-) create mode 100644 workflows/experimentals/bulk-import-git-repos/Makefile create mode 100644 workflows/experimentals/bulk-import-git-repos/README.md create mode 100644 workflows/experimentals/bulk-import-git-repos/argfile.conf create mode 100644 workflows/experimentals/bulk-import-git-repos/pom.xml create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml diff --git a/Makefile b/Makefile index 2d6717c1..f5f32000 100644 --- a/Makefile +++ b/Makefile @@ -165,8 +165,11 @@ save-oci: build-image # Depends on: prepare-workdir target. # Usage: make gen-manifests gen-manifests: prepare-workdir - cd $(WORKDIR) - $(CONTAINER_ENGINE) run --rm -v $(WORKDIR):/workdir:Z -w /workdir \ + @# Ensure WORKDIR exists and is accessible (important for macOS Podman) + @test -d $(WORKDIR) || mkdir -p $(WORKDIR) + @# Use absolute path for volume mount (required for Podman on macOS) + @# On macOS, use realpath or fallback to WORKDIR if realpath fails + @$(CONTAINER_ENGINE) run --rm -v "$(shell realpath $(WORKDIR) 2>/dev/null || echo $(WORKDIR)):/workdir:Z" -w /workdir \ $(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) WORKFLOW_IMAGE_TAG=$(IMAGE_TAG) ${SCRIPTS_DIR}/gen_manifests.sh workflows/$(WORKFLOW_ID) $(WORKFLOW_ID)" @echo "Manifests are available in workdir $(WORKDIR)/workflows/$(WORKFLOW_ID)/manifests" diff --git a/workflows/experimentals/bulk-import-git-repos/Makefile b/workflows/experimentals/bulk-import-git-repos/Makefile new file mode 100644 index 00000000..98f50ff0 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/Makefile @@ -0,0 +1,35 @@ +# Makefile for bulk-import-git-repos workflow +# Generates Kubernetes manifests locally + +WORKFLOW_ID := bulk-import-git-repos +WORKFLOW_IMAGE_REGISTRY ?= quay.io +WORKFLOW_IMAGE_NAMESPACE ?= orchestrator +WORKFLOW_IMAGE_REPO ?= serverless-workflow-$(WORKFLOW_ID) +WORKFLOW_IMAGE_TAG ?= latest +CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker) +LINUX_IMAGE ?= quay.io/orchestrator/ubi9-pipeline:latest + +.PHONY: gen-manifests clean help + +help: + @echo "Available targets:" + @echo " gen-manifests - Generate Kubernetes manifests" + @echo " clean - Remove generated manifests" + @echo "" + @echo "Variables:" + @echo " WORKFLOW_IMAGE_TAG - Image tag (default: latest)" + @echo " CONTAINER_ENGINE - docker or podman (default: auto-detect)" + +gen-manifests: + @echo "๐Ÿ› ๏ธ Generating manifests for $(WORKFLOW_ID)..." + @$(CONTAINER_ENGINE) run --rm \ + -v $(PWD):/workdir:Z \ + -w /workdir \ + $(LINUX_IMAGE) \ + /bin/bash -c "echo -e '\nkie.flyway.enabled=false' >> application.properties && kn-workflow gen-manifest --profile=gitops --namespace='' --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG)" + @echo "โœ… Manifests generated in ./manifests/" + +clean: + @echo "๐Ÿงน Cleaning generated manifests..." + @rm -rf manifests/ + @echo "โœ… Cleaned" diff --git a/workflows/experimentals/bulk-import-git-repos/README.md b/workflows/experimentals/bulk-import-git-repos/README.md new file mode 100644 index 00000000..32e26d71 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/README.md @@ -0,0 +1,28 @@ +# Bulk Import Git Repos Workflow + +This workflow creates pull requests (GitHub) or merge requests (GitLab) based on the `approvalTool` parameter. + +## Overview + +The workflow supports both GitHub and GitLab repositories and can create PRs/MRs with multiple files. + +## Input Schema + +The workflow expects the following input parameters: +- `approvalTool`: Either "GIT" for GitHub or "GITLAB" for GitLab +- `owner`: The owner/namespace of the repository +- `repo`: The repository name +- `baseBranch`: The base branch to create the PR/MR from +- `targetBranch`: The target branch name for the PR/MR + +## Workflow Steps + +1. **GetScafolderData**: Retrieves mock data with files to be added +2. **RouteToProvider**: Routes to either GitHub or GitLab workflow based on `approvalTool` +3. **GitHub Flow**: Creates branch, commits files, and creates a pull request +4. **GitLab Flow**: Searches for project, creates branch, commits files, and creates a merge request + +## Output + +- For GitHub: Returns PR URL in `PR_URL` output +- For GitLab: Returns MR URL in `MR_URL` output diff --git a/workflows/experimentals/bulk-import-git-repos/argfile.conf b/workflows/experimentals/bulk-import-git-repos/argfile.conf new file mode 100644 index 00000000..e9a5be76 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/argfile.conf @@ -0,0 +1,5 @@ +FLOW_NAME=Universal PR +FLOW_SUMMARY=Create Universal Pull/Merge Request +FLOW_DESCRIPTION=This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. +QUARKUS_EXTENSIONS=io.quarkiverse.openapi.generator:quarkus-openapi-generator:2.9.1-lts,org.kie:kie-addons-quarkus-monitoring-sonataflow,org.kie:kogito-addons-quarkus-jobs-knative-eventing,org.kie:kie-addons-quarkus-persistence-jdbc,io.quarkus:quarkus-jdbc-h2:3.15.4.redhat-00001,io.quarkus:quarkus-agroal:3.15.4.redhat-00001,io.quarkus:quarkus-flyway:3.15.4.redhat-00001 +MAVEN_ARGS_APPEND=-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=h2 -Dkogito.persistence.proto.marshaller=false diff --git a/workflows/experimentals/bulk-import-git-repos/pom.xml b/workflows/experimentals/bulk-import-git-repos/pom.xml new file mode 100644 index 00000000..a22bbe86 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/pom.xml @@ -0,0 +1,200 @@ + + + 4.0.0 + + io.janus.workflow + reproducer + 1.0.0-SNAPSHOT + + basic + + 3.14.0 + 21 + UTF-8 + UTF-8 + quarkus-bom + com.redhat.quarkus.platform + 3.8.6.SP2-redhat-00002 + true + 3.5.3 + 10.0.0 + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + org.kie.kogito + kogito-bom + ${kie.version} + pom + import + + + + + + io.quarkus + quarkus-jdbc-postgresql + + + io.quarkiverse.openapi.generator + quarkus-openapi-generator + 2.11.0-lts + + + io.quarkus + quarkus-oidc-client-filter + + + io.quarkus + quarkus-kubernetes + + + io.quarkus + quarkus-smallrye-health + + + io.quarkus + quarkus-resteasy-jackson + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-resteasy + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + org.kie + kie-addons-quarkus-knative-eventing + + + org.kie + kie-addons-quarkus-process-management + + + org.kie + kie-addons-quarkus-source-files + + + org.kie + kogito-addons-quarkus-data-index-inmemory + + + org.kie + kogito-addons-quarkus-jobs-service-embedded + + + org.apache.kie.sonataflow + sonataflow-quarkus + + + org.apache.kie.sonataflow + sonataflow-quarkus-devui + ${kie.version} + + + + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + ${quarkus.platform.version} + true + + + + build + generate-code + generate-code-tests + + + + + + maven-compiler-plugin + ${compiler-plugin.version} + + + -parameters + + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + + native + + + native + + + + false + native + + + + + + apache-public-repository-group + Apache Public Repository Group + https://repository.apache.org/content/groups/public/ + + + apache-snapshot-repository-group + Apache Snapshot Repository Group + https://repository.apache.org/content/groups/snapshots/ + + + \ No newline at end of file diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties b/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties new file mode 100644 index 00000000..21150184 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties @@ -0,0 +1,31 @@ +# This property is used to select the log level, which controls the amount +# of information logged on HTTP requests based on the severity of the events. +# Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. +# and see https://quarkus.io/guides/logging for documentation +quarkus.log.category."org.apache.http".level=DEBUG +quarkus.log.level=DEBUG + +# Datasource +quarkus.datasource.db-kind=postgresql +quarkus.datasource.jdbc.url=jdbc:postgresql://postgres.showcase.svc.cluster.local:5432/sonata +quarkus.datasource.username=sonata +quarkus.datasource.password=sonata + +# Persistence +kogito.persistence.type=jdbc +kogito.persistence.auto.ddl=false +kie.flyway.enabled=true + +quarkus.oidc.enabled=false +quarkus.kogito.devservices.enabled=false +quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true +quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github +# quarkus.rest-client.github_yaml.headers.Accept=application/vnd.github+json +# quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-github +# quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} + +# quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true +# quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two + +quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true +quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml b/workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml new file mode 100644 index 00000000..b8436912 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml @@ -0,0 +1,284 @@ +id: universal-pr +version: "1.0" +specVersion: "0.8" +name: "Create Universal Pull/Merge Request" +description: "This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter." +dataInputSchema: schemas/create-pr-universal-input-schema.json +functions: + # Common functions + - name: scafolderMock + type: expression + operation: | + { + "files": [ + { + "path": "README.md", + "content": "# Hello World" + }, + { + "path": "index.js", + "content": "console.log('Hello, world!');" + } + ] + } + - name: sysLog + type: custom + operation: sysout:INFO + + # GitHub functions + - name: getBranchSHA + operation: specs/github.yaml#getBranchSHA + - name: createCommit + operation: specs/github.yaml#createCommit + - name: createTree + operation: specs/github.yaml#createTree + - name: createBlob + operation: specs/github.yaml#createBlob + - name: createBranch + operation: specs/github.yaml#createBranch + - name: getCommitDetails + operation: specs/github.yaml#getCommitDetails + - name: createPullRequest + operation: specs/github.yaml#createPullRequest + - name: createNewBlob + type: expression + operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' + - name: githubSuccessResult + type: expression + operation: '{ + "result": { + "message": "PR created", + "outputs":[ + { + "key": "PR_URL", + "value": .prURL.html_url, + "format":"link" + } + ] + } + }' + + # GitLab functions + - name: searchProjects + operation: specs/gitlab.yaml#searchProjects + - name: getProject + operation: specs/gitlab.yaml#getProject + - name: gitlabCreateBranch + operation: specs/gitlab.yaml#createBranch + - name: gitlabCreateCommit + operation: specs/gitlab.yaml#createCommit + - name: gitlabCreateMergeRequest + operation: specs/gitlab.yaml#createMergeRequest + - name: gitlabSuccessResult + type: expression + operation: '{ + "result": { + "message": "Merge Request created", + "outputs":[ + { + "key": "MR_URL", + "value": .mrURL.web_url, + "format":"link" + } + ] + } + }' + +start: "GetScafolderData" +states: + - name: GetScafolderData + type: operation + actions: + - name: "Get Scafolder data" + functionRef: + refName: scafolderMock + actionDataFilter: + toStateData: .scafolderReponse + transition: RouteToProvider + + - name: RouteToProvider + type: switch + dataConditions: + - condition: '${ .approvalTool == "GIT" }' + transition: GitHubCreateBranch + - condition: '${ .approvalTool == "GITLAB" }' + transition: GitLabSearchProject + defaultCondition: + transition: ErrorUnknownProvider + + - name: ErrorUnknownProvider + type: inject + data: + error: "Unknown or unsupported approval tool" + approvalTool: "${ .approvalTool }" + end: true + + # GitHub workflow states + - name: GitHubCreateBranch + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) }' + - name: "GetHeadSha" + functionRef: + refName: getBranchSHA + arguments: + owner: .owner + repo: .repo + ref: '"heads/" + .baseBranch' + actionDataFilter: + toStateData: .latestSHA + - name: "getCommitDetails" + functionRef: + refName: getCommitDetails + arguments: + owner: .owner + repo: .repo + commit_sha: .latestSHA.object.sha + actionDataFilter: + toStateData: .commit + transition: GitHubCreateFiles + + - name: GitHubCreateFiles + type: foreach + inputCollection: "${ [.scafolderReponse.files[]] }" + iterationParam: currentFile + outputCollection: .blobs + actions: + - name: "createBlob" + functionRef: + refName: createBlob + arguments: + owner: .owner + repo: .repo + content: ($currentFile.content|tostring) + encoding: "utf-8" + - name: createNewBlob + functionRef: + refName: createNewBlob + transition: GitHubCreateNewTree + + - name: GitHubCreateNewTree + type: operation + actions: + - name: "createTree" + functionRef: + refName: createTree + arguments: + owner: .owner + repo: .repo + base_tree: .commit.tree.sha + tree: .blobs + actionDataFilter: + toStateData: .newTree + - name: "createCommit" + functionRef: + refName: createCommit + arguments: + owner: .owner + repo: .repo + message: "Added/Updated multiple files via API" + tree: .newTree.sha + parents: [.latestSHA.object.sha] + actionDataFilter: + toStateData: .newCommit + - name: "createBranch" + functionRef: + refName: createBranch + arguments: + owner: .owner + repo: .repo + ref: '"refs/heads/" + .targetBranch' + sha: .newCommit.sha + transition: GitHubCreatePR + + - name: GitHubCreatePR + type: operation + actions: + - name: "createPullRequest" + functionRef: + refName: createPullRequest + arguments: + owner: .owner + repo: .repo + title: "Automated PR" + body: "" + head: .targetBranch + base: .baseBranch + actionDataFilter: + toStateData: .prURL + - name: setOutput + functionRef: + refName: githubSuccessResult + end: true + + # GitLab workflow states + - name: GitLabSearchProject + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' + - name: SearchProjects + functionRef: + refName: searchProjects + arguments: + search: .repo + membership: true + per_page: 100 + actionDataFilter: + toStateData: .projectsList + stateDataFilter: + output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' + transition: GitLabCreateBranch + + - name: GitLabCreateBranch + type: operation + actions: + - functionRef: + refName: sysLog + arguments: + message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' + - name: "createBranch" + functionRef: + refName: gitlabCreateBranch + arguments: + id: .project.id | tostring + branch: .targetBranch + ref: .baseBranch + transition: GitLabCreateCommit + + - name: GitLabCreateCommit + type: operation + actions: + - name: "createCommit" + functionRef: + refName: gitlabCreateCommit + arguments: + id: .project.id | tostring + branch: .targetBranch + commit_message: "Added/Updated multiple files via API" + actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' + transition: GitLabCreateMR + + - name: GitLabCreateMR + type: operation + actions: + - name: "createMergeRequest" + functionRef: + refName: gitlabCreateMergeRequest + arguments: + id: .project.id | tostring + source_branch: .targetBranch + target_branch: .baseBranch + title: "Automated MR" + actionDataFilter: + toStateData: .mrURL + - name: setOutput + functionRef: + refName: gitlabSuccessResult + end: true + diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json b/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json new file mode 100644 index 00000000..93a0b5ac --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json @@ -0,0 +1,41 @@ +{ + "$id": "classpath:/schemas/create-pr-universal-input-schema.json", + "title": "Create Universal PR/MR Input Schema", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "approvalTool": { + "title": "Approval Tool", + "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", + "type": "string", + "enum": ["GIT", "GITLAB"] + }, + "owner": { + "title": "Owner", + "description": "The owner/namespace of the repository", + "type": "string" + }, + "repo": { + "title": "Repository", + "description": "The repository name", + "type": "string" + }, + "baseBranch": { + "title": "Base Branch", + "description": "The base branch to create the PR/MR from", + "type": "string" + }, + "targetBranch": { + "title": "Target Branch", + "description": "The target branch name for the PR/MR", + "type": "string" + } + }, + "required": [ + "approvalTool", + "owner", + "repo", + "baseBranch", + "targetBranch" + ] +} diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml b/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml new file mode 100644 index 00000000..b8856bc3 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml @@ -0,0 +1,312 @@ +openapi: 3.0.0 +info: + title: GitHub Repository Automation API + version: 1.0.0 + description: API specification for automating GitHub repository tasks using the GitHub REST API v3. + +servers: + - url: https://api.github.com + description: GitHub API +security: +- BearerToken: [] +paths: + /repos/{owner}/{repo}/git/refs/{ref}: + patch: + summary: Update a branch reference + operationId: updateBranchRef + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + sha: + type: string + force: + type: boolean + responses: + '200': + description: Branch updated successfully + content: + application/json: + schema: + type: object + get: + summary: Get the SHA of a ref + operationId: getBranchSHA + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved branch reference + content: + application/json: + schema: + type: object + properties: + object: + type: object + properties: + sha: + type: string + '404': + description: Branch not found + /repos/{owner}/{repo}/git/refs: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + ref: + type: string + sha: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/blobs: + post: + summary: Create a new blob + operationId: createBlob + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + content: + type: string + encoding: + type: string + responses: + '201': + description: Blob created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/trees: + post: + summary: Create a new tree + operationId: createTree + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + base_tree: + type: string + tree: + type: array + items: + type: object + properties: + path: + type: string + mode: + type: string + type: + type: string + sha: + type: string + responses: + '201': + description: Tree created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + message: + type: string + tree: + type: string + parents: + type: array + items: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/commits/{commit_sha}: + get: + summary: Get details of a commit + operationId: getCommitDetails + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: commit_sha + in: path + required: true + schema: + type: string + responses: + '200': + description: Commit details retrieved successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/pulls: + post: + summary: Create a pull request + description: Opens a new pull request from a branch to the base branch. + operationId: createPullRequest + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + title: + type: string + example: "New Feature: Added new file" + body: + type: string + example: "This PR adds a new file using the GitHub REST API." + head: + type: string + example: "new-feature-branch" + base: + type: string + example: "main" + responses: + '201': + description: Pull request created successfully. + content: + application/json: + schema: + type: object + properties: + html_url: + type: string + example: "https://github.com/user/repo/pull/42" + '422': + description: Invalid input or pull request already exists. +components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml b/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml new file mode 100644 index 00000000..e620d77e --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml @@ -0,0 +1,174 @@ +openapi: 3.0.0 +info: + title: GitLab Repository Automation API + version: 1.0.0 + description: API specification for automating GitLab repository tasks using the GitLab REST API v4. + +servers: + - url: https://gitlab.com/api/v4 + description: GitLab API +security: +- BearerToken: [] +paths: + /projects: + get: + summary: Search for projects + operationId: searchProjects + parameters: + - name: search + in: query + required: false + schema: + type: string + - name: membership + in: query + required: false + schema: + type: boolean + - name: per_page + in: query + required: false + schema: + type: integer + responses: + '200': + description: Successfully retrieved projects + content: + application/json: + schema: + type: array + items: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}: + get: + summary: Get project details + operationId: getProject + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved project + content: + application/json: + schema: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}/repository/branches: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + ref: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /projects/{id}/repository/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + commit_message: + type: string + actions: + type: array + items: + type: object + properties: + action: + type: string + file_path: + type: string + content: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /projects/{id}/merge_requests: + post: + summary: Create a merge request + operationId: createMergeRequest + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + source_branch: + type: string + target_branch: + type: string + title: + type: string + responses: + '201': + description: Merge request created successfully + content: + application/json: + schema: + type: object + properties: + web_url: + type: string +components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication diff --git a/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml b/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml index 5b5c8deb..e397fa92 100644 --- a/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml +++ b/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml @@ -1,7 +1,8 @@ apiVersion: v1 data: - NOTIFICATIONS_BEARER_TOKEN: "" + ghToken: Z2hwX0FCQzEyMw== kind: Secret +type: Opaque metadata: creationTimestamp: null name: gh-pr-secrets diff --git a/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml b/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml index 711f5dfe..70d77a53 100755 --- a/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml +++ b/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml @@ -212,14 +212,14 @@ spec: persistence: postgresql: secretRef: - name: sonataflow-psql-postgresql - userKey: postgres-username - passwordKey: postgres-password + name: backstage-psql-secret + userKey: POSTGRES_USER + passwordKey: POSTGRES_PASSWORD serviceRef: - name: sonataflow-psql-postgresql + name: backstage-psql port: 5432 - databaseName: sonataflow - databaseSchema: gh-pr + databaseName: postgres + databaseSchema: public status: address: {} lastTimeRecoverAttempt: null diff --git a/workflows/experimentals/github-pr/src/main/resources/application.properties b/workflows/experimentals/github-pr/src/main/resources/application.properties index 5b86e7e3..43f3840f 100644 --- a/workflows/experimentals/github-pr/src/main/resources/application.properties +++ b/workflows/experimentals/github-pr/src/main/resources/application.properties @@ -8,8 +8,10 @@ quarkus.log.category."org.apache.http".level=DEBUG quarkus.log.level=INFO quarkus.rest-client.scafolderMock_yaml.url=http://127.0.0.1:8282 quarkus.rest-client.github_yaml.url=https://api.github.com + + #ghToken= -#quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} +# quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} quarkus.kogito.devservices.enabled=false quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github \ No newline at end of file From d393445769dc5784f0f50eb200a92e3b2ebd3977 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Mon, 23 Feb 2026 14:50:53 +0200 Subject: [PATCH 04/14] add manifests --- .../application.properties | 2 + .../manifests/00-secret_gh-pr-secrets.yaml | 8 + .../01-configmap_universal-pr-props.yaml | 45 ++ ...map_01-universal-pr-resources-schemas.yaml | 48 ++ ...igmap_02-universal-pr-resources-specs.yaml | 494 ++++++++++++++++++ .../manifests/04-sonataflow_universal-pr.yaml | 370 +++++++++++++ 6 files changed, 967 insertions(+) create mode 100644 workflows/experimentals/bulk-import-git-repos/application.properties create mode 100644 workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml create mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml create mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml create mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml create mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml diff --git a/workflows/experimentals/bulk-import-git-repos/application.properties b/workflows/experimentals/bulk-import-git-repos/application.properties new file mode 100644 index 00000000..b97b1c00 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/application.properties @@ -0,0 +1,2 @@ + +kie.flyway.enabled=false diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml new file mode 100644 index 00000000..e397fa92 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +data: + ghToken: Z2hwX0FCQzEyMw== +kind: Secret +type: Opaque +metadata: + creationTimestamp: null + name: gh-pr-secrets diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml new file mode 100755 index 00000000..a0f80da0 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +data: + application.properties: | + # This property is used to select the log level, which controls the amount + # of information logged on HTTP requests based on the severity of the events. + # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. + # and see https://quarkus.io/guides/logging for documentation + quarkus.log.category."org.apache.http".level=DEBUG + quarkus.log.level=DEBUG + + # Datasource + quarkus.datasource.db-kind=postgresql + quarkus.datasource.jdbc.url=jdbc:postgresql://postgres.showcase.svc.cluster.local:5432/sonata + quarkus.datasource.username=sonata + quarkus.datasource.password=sonata + + # Persistence + kogito.persistence.type=jdbc + kogito.persistence.auto.ddl=false + kie.flyway.enabled=true + + quarkus.oidc.enabled=false + quarkus.kogito.devservices.enabled=false + quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true + quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github + # quarkus.rest-client.github_yaml.headers.Accept=application/vnd.github+json + # quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-github + # quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} + + # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true + # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two + + quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true + quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab +kind: ConfigMap +metadata: + creationTimestamp: null + labels: + app: universal-pr + app.kubernetes.io/component: serverless-workflow + app.kubernetes.io/managed-by: sonataflow-operator + app.kubernetes.io/name: universal-pr + sonataflow.org/workflow-app: universal-pr + sonataflow.org/workflow-namespace: "" + name: universal-pr-props diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml new file mode 100755 index 00000000..e1bc69b9 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml @@ -0,0 +1,48 @@ +apiVersion: v1 +data: + create-pr-universal-input-schema.json: | + { + "$id": "classpath:/schemas/create-pr-universal-input-schema.json", + "title": "Create Universal PR/MR Input Schema", + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "approvalTool": { + "title": "Approval Tool", + "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", + "type": "string", + "enum": ["GIT", "GITLAB"] + }, + "owner": { + "title": "Owner", + "description": "The owner/namespace of the repository", + "type": "string" + }, + "repo": { + "title": "Repository", + "description": "The repository name", + "type": "string" + }, + "baseBranch": { + "title": "Base Branch", + "description": "The base branch to create the PR/MR from", + "type": "string" + }, + "targetBranch": { + "title": "Target Branch", + "description": "The target branch name for the PR/MR", + "type": "string" + } + }, + "required": [ + "approvalTool", + "owner", + "repo", + "baseBranch", + "targetBranch" + ] + } +kind: ConfigMap +metadata: + creationTimestamp: null + name: 01-universal-pr-resources-schemas diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml new file mode 100755 index 00000000..21413170 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml @@ -0,0 +1,494 @@ +apiVersion: v1 +data: + github.yaml: | + openapi: 3.0.0 + info: + title: GitHub Repository Automation API + version: 1.0.0 + description: API specification for automating GitHub repository tasks using the GitHub REST API v3. + + servers: + - url: https://api.github.com + description: GitHub API + security: + - BearerToken: [] + paths: + /repos/{owner}/{repo}/git/refs/{ref}: + patch: + summary: Update a branch reference + operationId: updateBranchRef + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + sha: + type: string + force: + type: boolean + responses: + '200': + description: Branch updated successfully + content: + application/json: + schema: + type: object + get: + summary: Get the SHA of a ref + operationId: getBranchSHA + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved branch reference + content: + application/json: + schema: + type: object + properties: + object: + type: object + properties: + sha: + type: string + '404': + description: Branch not found + /repos/{owner}/{repo}/git/refs: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + ref: + type: string + sha: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/blobs: + post: + summary: Create a new blob + operationId: createBlob + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + content: + type: string + encoding: + type: string + responses: + '201': + description: Blob created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/trees: + post: + summary: Create a new tree + operationId: createTree + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + base_tree: + type: string + tree: + type: array + items: + type: object + properties: + path: + type: string + mode: + type: string + type: + type: string + sha: + type: string + responses: + '201': + description: Tree created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + message: + type: string + tree: + type: string + parents: + type: array + items: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/git/commits/{commit_sha}: + get: + summary: Get details of a commit + operationId: getCommitDetails + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: commit_sha + in: path + required: true + schema: + type: string + responses: + '200': + description: Commit details retrieved successfully + content: + application/json: + schema: + type: object + /repos/{owner}/{repo}/pulls: + post: + summary: Create a pull request + description: Opens a new pull request from a branch to the base branch. + operationId: createPullRequest + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + title: + type: string + example: "New Feature: Added new file" + body: + type: string + example: "This PR adds a new file using the GitHub REST API." + head: + type: string + example: "new-feature-branch" + base: + type: string + example: "main" + responses: + '201': + description: Pull request created successfully. + content: + application/json: + schema: + type: object + properties: + html_url: + type: string + example: "https://github.com/user/repo/pull/42" + '422': + description: Invalid input or pull request already exists. + components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication + gitlab.yaml: | + openapi: 3.0.0 + info: + title: GitLab Repository Automation API + version: 1.0.0 + description: API specification for automating GitLab repository tasks using the GitLab REST API v4. + + servers: + - url: https://gitlab.com/api/v4 + description: GitLab API + security: + - BearerToken: [] + paths: + /projects: + get: + summary: Search for projects + operationId: searchProjects + parameters: + - name: search + in: query + required: false + schema: + type: string + - name: membership + in: query + required: false + schema: + type: boolean + - name: per_page + in: query + required: false + schema: + type: integer + responses: + '200': + description: Successfully retrieved projects + content: + application/json: + schema: + type: array + items: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}: + get: + summary: Get project details + operationId: getProject + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully retrieved project + content: + application/json: + schema: + type: object + properties: + id: + type: integer + path_with_namespace: + type: string + /projects/{id}/repository/branches: + post: + summary: Create a new branch + operationId: createBranch + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + ref: + type: string + responses: + '201': + description: Branch created successfully + content: + application/json: + schema: + type: object + /projects/{id}/repository/commits: + post: + summary: Create a new commit + operationId: createCommit + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + branch: + type: string + commit_message: + type: string + actions: + type: array + items: + type: object + properties: + action: + type: string + file_path: + type: string + content: + type: string + responses: + '201': + description: Commit created successfully + content: + application/json: + schema: + type: object + /projects/{id}/merge_requests: + post: + summary: Create a merge request + operationId: createMergeRequest + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + source_branch: + type: string + target_branch: + type: string + title: + type: string + responses: + '201': + description: Merge request created successfully + content: + application/json: + schema: + type: object + properties: + web_url: + type: string + components: + securitySchemes: + BearerToken: + type: http + scheme: bearer + description: Bearer Token authentication +kind: ConfigMap +metadata: + creationTimestamp: null + name: 02-universal-pr-resources-specs diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml new file mode 100755 index 00000000..dd13e689 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml @@ -0,0 +1,370 @@ +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + annotations: + sonataflow.org/description: This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. + sonataflow.org/expressionLang: jq + sonataflow.org/profile: gitops + sonataflow.org/version: "1.0" + creationTimestamp: null + labels: + app: universal-pr + app.kubernetes.io/component: serverless-workflow + app.kubernetes.io/managed-by: sonataflow-operator + app.kubernetes.io/name: universal-pr + sonataflow.org/workflow-app: universal-pr + sonataflow.org/workflow-namespace: "" + name: universal-pr +spec: + flow: + dataInputSchema: + failOnValidationErrors: true + schema: schemas/create-pr-universal-input-schema.json + functions: + - name: scafolderMock + operation: | + { + "files": [ + { + "path": "README.md", + "content": "# Hello World" + }, + { + "path": "index.js", + "content": "console.log('Hello, world!');" + } + ] + } + type: expression + - name: sysLog + operation: sysout:INFO + type: custom + - name: getBranchSHA + operation: specs/github.yaml#getBranchSHA + type: rest + - name: createCommit + operation: specs/github.yaml#createCommit + type: rest + - name: createTree + operation: specs/github.yaml#createTree + type: rest + - name: createBlob + operation: specs/github.yaml#createBlob + type: rest + - name: createBranch + operation: specs/github.yaml#createBranch + type: rest + - name: getCommitDetails + operation: specs/github.yaml#getCommitDetails + type: rest + - name: createPullRequest + operation: specs/github.yaml#createPullRequest + type: rest + - name: createNewBlob + operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' + type: expression + - name: githubSuccessResult + operation: '{ "result": { "message": "PR created", "outputs":[ { "key": "PR_URL", "value": .prURL.html_url, "format":"link" } ] } }' + type: expression + - name: searchProjects + operation: specs/gitlab.yaml#searchProjects + type: rest + - name: getProject + operation: specs/gitlab.yaml#getProject + type: rest + - name: gitlabCreateBranch + operation: specs/gitlab.yaml#createBranch + type: rest + - name: gitlabCreateCommit + operation: specs/gitlab.yaml#createCommit + type: rest + - name: gitlabCreateMergeRequest + operation: specs/gitlab.yaml#createMergeRequest + type: rest + - name: gitlabSuccessResult + operation: '{ "result": { "message": "Merge Request created", "outputs":[ { "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }' + type: expression + start: + stateName: GetScafolderData + states: + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .scafolderReponse + useResults: true + functionRef: + invoke: sync + refName: scafolderMock + name: Get Scafolder data + name: GetScafolderData + transition: + nextState: RouteToProvider + type: operation + - dataConditions: + - condition: ${ .approvalTool == "GIT" } + transition: + nextState: GitHubCreateBranch + - condition: ${ .approvalTool == "GITLAB" } + transition: + nextState: GitLabSearchProject + defaultCondition: + transition: + nextState: ErrorUnknownProvider + name: RouteToProvider + type: switch + - data: + approvalTool: ${ .approvalTool } + error: Unknown or unsupported approval tool + end: + terminate: true + name: ErrorUnknownProvider + type: inject + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: ${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) } + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .latestSHA + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"heads/" + .baseBranch' + repo: .repo + invoke: sync + refName: getBranchSHA + name: GetHeadSha + - actionDataFilter: + toStateData: .commit + useResults: true + functionRef: + arguments: + commit_sha: .latestSHA.object.sha + owner: .owner + repo: .repo + invoke: sync + refName: getCommitDetails + name: getCommitDetails + name: GitHubCreateBranch + transition: + nextState: GitHubCreateFiles + type: operation + - actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + content: ($currentFile.content|tostring) + encoding: utf-8 + owner: .owner + repo: .repo + invoke: sync + refName: createBlob + name: createBlob + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: createNewBlob + name: createNewBlob + inputCollection: ${ [.scafolderReponse.files[]] } + iterationParam: currentFile + mode: parallel + name: GitHubCreateFiles + outputCollection: .blobs + transition: + nextState: GitHubCreateNewTree + type: foreach + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .newTree + useResults: true + functionRef: + arguments: + base_tree: .commit.tree.sha + owner: .owner + repo: .repo + tree: .blobs + invoke: sync + refName: createTree + name: createTree + - actionDataFilter: + toStateData: .newCommit + useResults: true + functionRef: + arguments: + message: Added/Updated multiple files via API + owner: .owner + parents: + - .latestSHA.object.sha + repo: .repo + tree: .newTree.sha + invoke: sync + refName: createCommit + name: createCommit + - actionDataFilter: + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"refs/heads/" + .targetBranch' + repo: .repo + sha: .newCommit.sha + invoke: sync + refName: createBranch + name: createBranch + name: GitHubCreateNewTree + transition: + nextState: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .prURL + useResults: true + functionRef: + arguments: + base: .baseBranch + body: "" + head: .targetBranch + owner: .owner + repo: .repo + title: Automated PR + invoke: sync + refName: createPullRequest + name: createPullRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: githubSuccessResult + name: setOutput + end: + terminate: true + name: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .projectsList + useResults: true + functionRef: + arguments: + membership: true + per_page: 100 + search: .repo + invoke: sync + refName: searchProjects + name: SearchProjects + name: GitLabSearchProject + stateDataFilter: + output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' + transition: + nextState: GitLabCreateBranch + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + useResults: true + functionRef: + arguments: + branch: .targetBranch + id: .project.id | tostring + ref: .baseBranch + invoke: sync + refName: gitlabCreateBranch + name: createBranch + name: GitLabCreateBranch + transition: + nextState: GitLabCreateCommit + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' + branch: .targetBranch + commit_message: Added/Updated multiple files via API + id: .project.id | tostring + invoke: sync + refName: gitlabCreateCommit + name: createCommit + name: GitLabCreateCommit + transition: + nextState: GitLabCreateMR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .mrURL + useResults: true + functionRef: + arguments: + id: .project.id | tostring + source_branch: .targetBranch + target_branch: .baseBranch + title: Automated MR + invoke: sync + refName: gitlabCreateMergeRequest + name: createMergeRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: gitlabSuccessResult + name: setOutput + end: + terminate: true + name: GitLabCreateMR + type: operation + podTemplate: + container: + image: quay.io/aandriienko/example-token-propagation + resources: {} + envFrom: + - secretRef: + name: gh-pr-secrets + resources: + configMaps: + - configMap: + name: 01-universal-pr-resources-schemas + workflowPath: schemas + - configMap: + name: 02-universal-pr-resources-specs + workflowPath: specs + persistence: + postgresql: + secretRef: + name: postgres-secret + userKey: POSTGRESQL_USER + passwordKey: POSTGRESQL_PASSWORD + serviceRef: + name: postgres + port: 5432 + databaseName: sonata + databaseSchema: public +status: + address: {} + lastTimeRecoverAttempt: null From 3031cdaffebe2d31df148fbcccdc9f1f4faa1e8d Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 03:46:08 +0200 Subject: [PATCH 05/14] feat(bulk-import-workflow): automate workflow manifest, image build Signed-off-by: Oleksandr Andriienko --- .github/workflows/bulk-import-git-repos.yml | 19 ++++++++++ Makefile | 11 ++++-- pipeline/workflow-builder.Dockerfile | 8 +++-- scripts/gen_manifests.sh | 5 ++- .../bulk-import-git-repos/Makefile | 35 ------------------- .../bulk-import-git-repos/README.md | 20 +++++++++++ .../bulk-import-git-repos/argfile.conf | 5 +-- .../01-configmap_universal-pr-props.yaml | 3 ++ .../manifests/04-sonataflow_universal-pr.yaml | 15 ++++---- .../bulk-import-git-repos/pom.xml | 23 ++++++++---- .../src/main/docker/Dockerfile.jvm | 34 ++++++++++++++++++ .../src/main/resources/application.properties | 1 + 12 files changed, 123 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/bulk-import-git-repos.yml delete mode 100644 workflows/experimentals/bulk-import-git-repos/Makefile create mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm diff --git a/.github/workflows/bulk-import-git-repos.yml b/.github/workflows/bulk-import-git-repos.yml new file mode 100644 index 00000000..0c9cd26b --- /dev/null +++ b/.github/workflows/bulk-import-git-repos.yml @@ -0,0 +1,19 @@ +name: Bulk Import Git Repos workflow container image and manifest push + +on: + workflow_dispatch: + push: + branches: [ "main" ] + paths: + - 'workflows/experimentals/bulk-import-git-repos/**' + - 'pipeline/**' + - 'scripts/**' + - .github/workflows/bulk-import-git-repos.yml + - .github/workflows/main.yml + +jobs: + bulk-import-git-repos: + uses: ./.github/workflows/main.yml + with: + workflow_id: experimentals/bulk-import-git-repos + secrets: inherit diff --git a/Makefile b/Makefile index f5f32000..bf64e100 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,10 @@ else DOCKERFILE ?= src/main/docker/Dockerfile.jvm endif +# For image name strip experimentals/ prefix so image is serverless-workflow-bulk-import-git-repos not serverless-workflow-experimentals/bulk-import-git-repos +WORKFLOW_ID_FOR_IMAGE ?= $(patsubst experimentals/%,%,$(WORKFLOW_ID)) ifeq ($(IS_WORKFLOW),true) -IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(WORKFLOW_ID) +IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(WORKFLOW_ID_FOR_IMAGE) else IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(APPLICATION_ID) endif @@ -164,14 +166,17 @@ save-oci: build-image # Description: Generates the k8s manifests for the WORKFLOW_ID workflow under the configured WORKDIR. # Depends on: prepare-workdir target. # Usage: make gen-manifests +# Optional: WORKFLOW_SUBDIR โ€” when set, first arg is workflows/$(WORKFLOW_SUBDIR); when unset, workflows/$(WORKFLOW_ID) +# make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=experimentals/bulk-import-git-repos/src/main/resources gen-manifests +GEN_MANIFESTS_WORKFLOW_FOLDER = workflows/$(if $(WORKFLOW_SUBDIR),$(WORKFLOW_SUBDIR),$(WORKFLOW_ID)) gen-manifests: prepare-workdir @# Ensure WORKDIR exists and is accessible (important for macOS Podman) @test -d $(WORKDIR) || mkdir -p $(WORKDIR) @# Use absolute path for volume mount (required for Podman on macOS) @# On macOS, use realpath or fallback to WORKDIR if realpath fails @$(CONTAINER_ENGINE) run --rm -v "$(shell realpath $(WORKDIR) 2>/dev/null || echo $(WORKDIR)):/workdir:Z" -w /workdir \ - $(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) WORKFLOW_IMAGE_TAG=$(IMAGE_TAG) ${SCRIPTS_DIR}/gen_manifests.sh workflows/$(WORKFLOW_ID) $(WORKFLOW_ID)" - @echo "Manifests are available in workdir $(WORKDIR)/workflows/$(WORKFLOW_ID)/manifests" + $(LINUX_IMAGE) /bin/bash -c "ENABLE_PERSISTENCE=$(ENABLE_PERSISTENCE) WORKFLOW_IMAGE_TAG=$(IMAGE_TAG) ${SCRIPTS_DIR}/gen_manifests.sh $(GEN_MANIFESTS_WORKFLOW_FOLDER) $(WORKFLOW_ID)" + @echo "Manifests are available in workdir $(WORKDIR)/$(GEN_MANIFESTS_WORKFLOW_FOLDER)/manifests" remove-trailing-whitespaces: @echo "Removing all trailing whitespaces from application.properties files" diff --git a/pipeline/workflow-builder.Dockerfile b/pipeline/workflow-builder.Dockerfile index 818e7b8e..0d1191b4 100644 --- a/pipeline/workflow-builder.Dockerfile +++ b/pipeline/workflow-builder.Dockerfile @@ -33,6 +33,10 @@ ARG QUARKUS_EXTENSIONS=io.quarkiverse.openapi.generator:quarkus-openapi-generato # YAML input files, and is currently set to 35000000 characters (~33MB in UTF-8). ARG MAVEN_ARGS_APPEND="-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=postgresql -Dkogito.persistence.proto.marshaller=false" +# Expose to RUN so build-app.sh can use them (--build-arg-file from argfile.conf overrides ARG above) +ENV QUARKUS_EXTENSIONS=${QUARKUS_EXTENSIONS} +ENV MAVEN_ARGS_APPEND=${MAVEN_ARGS_APPEND} + # Argument for passing the resources folder if not current context dir ARG WF_RESOURCES @@ -41,8 +45,8 @@ COPY --chown=1001 ${WF_RESOURCES} ./resources/ RUN ls -la ./resources ENV swf_home_dir=/home/kogito/serverless-workflow-project -RUN if [[ -d "./resources/src" ]]; then cp -r ./resources/src/* ./src/; fi - +# Do not cp resources/src to ./src to avoid duplicate workflow id (Kogito scans both and fails with "Duplicated item found with id") +# build-app.sh ./resources builds from ./resources only. RUN /home/kogito/launch/build-app.sh ./resources #============================= diff --git a/scripts/gen_manifests.sh b/scripts/gen_manifests.sh index a356e464..bc0ee61a 100755 --- a/scripts/gen_manifests.sh +++ b/scripts/gen_manifests.sh @@ -18,7 +18,10 @@ command -v kubectl cd "${WORKFLOW_FOLDER}" -echo -e "\nkie.flyway.enabled=true" >> application.properties +# Append to application.properties when present (WORKFLOW_FOLDER is already the dir with .sw.yaml, possibly a subdir) +if [ -f application.properties ]; then + echo -e "\nkie.flyway.enabled=true" >> application.properties +fi kn-workflow gen-manifest --profile='gitops' \ --image="${WORKFLOW_IMAGE_REGISTRY}/${WORKFLOW_IMAGE_NAMESPACE}/${WORKFLOW_IMAGE_REPO}:${WORKFLOW_IMAGE_TAG}" \ diff --git a/workflows/experimentals/bulk-import-git-repos/Makefile b/workflows/experimentals/bulk-import-git-repos/Makefile deleted file mode 100644 index 98f50ff0..00000000 --- a/workflows/experimentals/bulk-import-git-repos/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Makefile for bulk-import-git-repos workflow -# Generates Kubernetes manifests locally - -WORKFLOW_ID := bulk-import-git-repos -WORKFLOW_IMAGE_REGISTRY ?= quay.io -WORKFLOW_IMAGE_NAMESPACE ?= orchestrator -WORKFLOW_IMAGE_REPO ?= serverless-workflow-$(WORKFLOW_ID) -WORKFLOW_IMAGE_TAG ?= latest -CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker) -LINUX_IMAGE ?= quay.io/orchestrator/ubi9-pipeline:latest - -.PHONY: gen-manifests clean help - -help: - @echo "Available targets:" - @echo " gen-manifests - Generate Kubernetes manifests" - @echo " clean - Remove generated manifests" - @echo "" - @echo "Variables:" - @echo " WORKFLOW_IMAGE_TAG - Image tag (default: latest)" - @echo " CONTAINER_ENGINE - docker or podman (default: auto-detect)" - -gen-manifests: - @echo "๐Ÿ› ๏ธ Generating manifests for $(WORKFLOW_ID)..." - @$(CONTAINER_ENGINE) run --rm \ - -v $(PWD):/workdir:Z \ - -w /workdir \ - $(LINUX_IMAGE) \ - /bin/bash -c "echo -e '\nkie.flyway.enabled=false' >> application.properties && kn-workflow gen-manifest --profile=gitops --namespace='' --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG)" - @echo "โœ… Manifests generated in ./manifests/" - -clean: - @echo "๐Ÿงน Cleaning generated manifests..." - @rm -rf manifests/ - @echo "โœ… Cleaned" diff --git a/workflows/experimentals/bulk-import-git-repos/README.md b/workflows/experimentals/bulk-import-git-repos/README.md index 32e26d71..d8af3a19 100644 --- a/workflows/experimentals/bulk-import-git-repos/README.md +++ b/workflows/experimentals/bulk-import-git-repos/README.md @@ -26,3 +26,23 @@ The workflow expects the following input parameters: - For GitHub: Returns PR URL in `PR_URL` output - For GitLab: Returns MR URL in `MR_URL` output + +# Development + +Java artifacts build(prerequisites: pre-installed java and maven): + +``` +mvn clean install +``` + +Generate manifests, from the root of the repository: + +``` +make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=experimentals/bulk-import-git-repos/src/main/resources gen-manifests +``` + +Build image: + +``` +make WORKFLOW_ID=experimentals/bulk-import-git-repos build-image +``` diff --git a/workflows/experimentals/bulk-import-git-repos/argfile.conf b/workflows/experimentals/bulk-import-git-repos/argfile.conf index e9a5be76..bfeb7ccc 100644 --- a/workflows/experimentals/bulk-import-git-repos/argfile.conf +++ b/workflows/experimentals/bulk-import-git-repos/argfile.conf @@ -1,5 +1,6 @@ FLOW_NAME=Universal PR FLOW_SUMMARY=Create Universal Pull/Merge Request FLOW_DESCRIPTION=This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. -QUARKUS_EXTENSIONS=io.quarkiverse.openapi.generator:quarkus-openapi-generator:2.9.1-lts,org.kie:kie-addons-quarkus-monitoring-sonataflow,org.kie:kogito-addons-quarkus-jobs-knative-eventing,org.kie:kie-addons-quarkus-persistence-jdbc,io.quarkus:quarkus-jdbc-h2:3.15.4.redhat-00001,io.quarkus:quarkus-agroal:3.15.4.redhat-00001,io.quarkus:quarkus-flyway:3.15.4.redhat-00001 -MAVEN_ARGS_APPEND=-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=h2 -Dkogito.persistence.proto.marshaller=false +# Base extensions (JARs included in image): persistence-jdbc, jdbc-postgresql, openapi-generator, oidc-client-filter, oidc, agroal +QUARKUS_EXTENSIONS=org.kie:kie-addons-quarkus-persistence-jdbc,io.quarkus:quarkus-jdbc-postgresql:3.15.4.redhat-00001,io.quarkiverse.openapi.generator:quarkus-openapi-generator:2.9.1-lts,io.quarkus:quarkus-oidc-client-filter,io.quarkus:quarkus-oidc,io.quarkus:quarkus-agroal:3.15.4.redhat-00001,org.kie:kie-addons-quarkus-monitoring-sonataflow,org.kie:kogito-addons-quarkus-jobs-knative-eventing +MAVEN_ARGS_APPEND=-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=postgresql -Dkogito.persistence.proto.marshaller=false diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml index a0f80da0..5928ec1c 100755 --- a/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml +++ b/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml @@ -20,6 +20,7 @@ data: kie.flyway.enabled=true quarkus.oidc.enabled=false + quarkus.oidc.tenant-enabled=false quarkus.kogito.devservices.enabled=false quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github @@ -32,6 +33,8 @@ data: quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab + + kie.flyway.enabled=true kind: ConfigMap metadata: creationTimestamp: null diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml index dd13e689..ef17aabd 100755 --- a/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml +++ b/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml @@ -341,7 +341,7 @@ spec: type: operation podTemplate: container: - image: quay.io/aandriienko/example-token-propagation + image: quay.io/aandriienko/serverless-workflow-bulk-import-git-repos:latest resources: {} envFrom: - secretRef: @@ -357,14 +357,15 @@ spec: persistence: postgresql: secretRef: - name: postgres-secret - userKey: POSTGRESQL_USER - passwordKey: POSTGRESQL_PASSWORD + name: "backstage-psql-secret" + userKey: "POSTGRES_USER" + passwordKey: "POSTGRES_PASSWORD" serviceRef: - name: postgres + name: "backstage-psql" port: 5432 - databaseName: sonata - databaseSchema: public + databaseName: "backstage_plugin_orchestrator" + databaseSchema: bulk-import-git-repos + namespace: "orchestrator" status: address: {} lastTimeRecoverAttempt: null diff --git a/workflows/experimentals/bulk-import-git-repos/pom.xml b/workflows/experimentals/bulk-import-git-repos/pom.xml index a22bbe86..fbf6a5ef 100644 --- a/workflows/experimentals/bulk-import-git-repos/pom.xml +++ b/workflows/experimentals/bulk-import-git-repos/pom.xml @@ -3,12 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - - io.janus.workflow - reproducer - 1.0.0-SNAPSHOT - + io.janus.workflow basic + 1.0.0-SNAPSHOT 3.14.0 21 @@ -47,7 +44,7 @@ io.quarkiverse.openapi.generator quarkus-openapi-generator - 2.11.0-lts + 2.9.1-lts io.quarkus @@ -186,6 +183,12 @@ + + true + false + redhat + https://maven.repository.redhat.com/ga + apache-public-repository-group Apache Public Repository Group @@ -197,4 +200,12 @@ https://repository.apache.org/content/groups/snapshots/ + + + true + false + redhat + https://maven.repository.redhat.com/ga + + \ No newline at end of file diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm b/workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm new file mode 100644 index 00000000..78705d71 --- /dev/null +++ b/workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm @@ -0,0 +1,34 @@ +ARG BUILDER_IMAGE +ARG RUNTIME_IMAGE + +# registry.redhat.io/openshift-serverless-1/logic-swf-devmode-rhel8:1.36.0 +FROM ${BUILDER_IMAGE:-registry.redhat.io/openshift-serverless-1/logic-swf-builder-rhel8:1.35.0-6} AS builder + +ARG QUARKUS_EXTENSIONS +ENV QUARKUS_EXTENSIONS=${QUARKUS_EXTENSIONS} + +ARG MAVEN_ARGS_APPEND +ENV MAVEN_ARGS_APPEND=${MAVEN_ARGS_APPEND} + +COPY --chown=1001 . . + +RUN /home/kogito/launch/build-app.sh + +#============================= +# Runtime +#============================= +FROM ${RUNTIME_IMAGE:-registry.access.redhat.com/ubi9/openjdk-17:1.21-2} + +ENV LANGUAGE='en_US:en' LANG='en_US.UTF-8' + +COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/*.jar /deployments/ +COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/app/ /deployments/app/ +COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties b/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties index 21150184..3e147352 100644 --- a/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties +++ b/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties @@ -17,6 +17,7 @@ kogito.persistence.auto.ddl=false kie.flyway.enabled=true quarkus.oidc.enabled=false +quarkus.oidc.tenant-enabled=false quarkus.kogito.devservices.enabled=false quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github From c500460301a6840f5423dccf5d40fea5809bcc71 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 03:48:23 +0200 Subject: [PATCH 06/14] feat(bulk-import-workflow): temp Signed-off-by: Oleksandr Andriienko --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf64e100..237615d4 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,8 @@ MVN_OPTS ?= -B IMAGE_NAME := "" REGISTRY ?= quay.io -REGISTRY_REPO ?= $(shell id -un) +REGISTRY_REPO ?= "aandriienko" +#$(shell id -un) REGISTRY_USERNAME ?= "" REGISTRY_PASSWORD ?= "" IMAGE_PREFIX ?= serverless-workflow From f667b915b113360bbf97725fd561600f98095965 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 04:03:35 +0200 Subject: [PATCH 07/14] temp Signed-off-by: Oleksandr Andriienko --- .github/workflows/main.yml | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6aa0b79c..398f3c06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ permissions: env: WF_DEPLOY_REPO: rhdhorchestrator/serverless-workflows REGISTRY_REPO: orchestrator - GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} + # GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} jobs: build: @@ -121,30 +121,30 @@ jobs: }) ).data[0]; - - name: Send PRs to deploy repo - if: ${{ ! inputs.it_mode }} - env: - GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} - run: | - gh auth status - - WORKDIR=${{ runner.temp }}/serverless-workflows - - # determine pr or commit url - if [ ${{ fromJSON(steps.get_pr_data.outputs.result)}} != "" ]; then - PR_OR_COMMIT_URL="${{ fromJSON(steps.get_pr_data.outputs.result).html_url }}" - else - PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - fi - - sh scripts/create_or_update_automated_pr.sh $WF_DEPLOY_REPO \ - ${{ inputs.workflow_id }} \ - ${PR_OR_COMMIT_URL} \ - "" \ - scripts/create_automated_pr.sh \ - 'rhdhorchestrator@redhat.com' \ - 'orchestrator-ci' \ - $WORKDIR \ - ${{ env.GH_TOKEN }} \ - ${{ github.sha }} + # - name: Send PRs to deploy repo + # if: ${{ ! inputs.it_mode }} + # env: + # GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} + # run: | + # gh auth status + + # WORKDIR=${{ runner.temp }}/serverless-workflows + + # # determine pr or commit url + # if [ ${{ fromJSON(steps.get_pr_data.outputs.result)}} != "" ]; then + # PR_OR_COMMIT_URL="${{ fromJSON(steps.get_pr_data.outputs.result).html_url }}" + # else + # PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + # fi + + # sh scripts/create_or_update_automated_pr.sh $WF_DEPLOY_REPO \ + # ${{ inputs.workflow_id }} \ + # ${PR_OR_COMMIT_URL} \ + # "" \ + # scripts/create_automated_pr.sh \ + # 'rhdhorchestrator@redhat.com' \ + # 'orchestrator-ci' \ + # $WORKDIR \ + # ${{ env.GH_TOKEN }} \ + # ${{ github.sha }} From 8a6cc13aabdaec3990f1bfc895fab4cf923375c2 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 04:06:57 +0200 Subject: [PATCH 08/14] temp Signed-off-by: Oleksandr Andriienko --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 398f3c06..213a120c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ on: default: false secrets: HELM_REPO_TOKEN: - required: true + required: false permissions: contents: write @@ -26,7 +26,7 @@ permissions: env: WF_DEPLOY_REPO: rhdhorchestrator/serverless-workflows - REGISTRY_REPO: orchestrator + REGISTRY_REPO: aandriienko # GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} jobs: From 6953cb8359797c657d8401dad1554a61412638d2 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 12:34:40 +0200 Subject: [PATCH 09/14] cleanup Signed-off-by: Oleksandr Andriienko --- .github/workflows/bulk-import-git-repos.yml | 2 +- Makefile | 6 +- workflows/bulk-import-git-repos/Makefile | 35 - workflows/bulk-import-git-repos/README.md | 20 + .../application.properties | 16 - workflows/bulk-import-git-repos/argfile.conf | 9 +- .../create-pr-universal.sw.yaml | 294 -------- .../manifests/00-secret_gh-pr-secrets.yaml | 0 .../01-configmap_universal-pr-props.yaml | 40 +- ...igmap_02-universal-pr-resources-specs.yaml | 92 +-- .../manifests/04-sonataflow_universal-pr.yaml | 680 +++++++++--------- .../bulk-import-git-repos/pom.xml | 0 .../bulk-import-git-repos/specs/github.yaml | 328 --------- .../src/main/docker/Dockerfile.jvm | 0 .../src/main/resources/application.properties | 0 .../resources/create-pr-universal.sw.yaml | 0 .../create-pr-universal-input-schema.json | 0 .../src/main/resources/specs/github.yaml | 0 .../main/resources}/specs/gitlab.yaml | 0 .../bulk-import-git-repos/README.md | 48 -- .../application.properties | 2 - .../bulk-import-git-repos/argfile.conf | 6 - .../01-configmap_universal-pr-props.yaml | 48 -- ...map_01-universal-pr-resources-schemas.yaml | 48 -- ...igmap_02-universal-pr-resources-specs.yaml | 494 ------------- .../manifests/04-sonataflow_universal-pr.yaml | 371 ---------- .../create-pr-universal-input-schema.json | 41 -- .../src/main/resources/specs/gitlab.yaml | 174 ----- 28 files changed, 437 insertions(+), 2317 deletions(-) delete mode 100644 workflows/bulk-import-git-repos/Makefile delete mode 100644 workflows/bulk-import-git-repos/create-pr-universal.sw.yaml rename workflows/{experimentals => }/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml (100%) rename workflows/{experimentals => }/bulk-import-git-repos/pom.xml (100%) delete mode 100644 workflows/bulk-import-git-repos/specs/github.yaml rename workflows/{experimentals => }/bulk-import-git-repos/src/main/docker/Dockerfile.jvm (100%) rename workflows/{experimentals => }/bulk-import-git-repos/src/main/resources/application.properties (100%) rename workflows/{experimentals => }/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml (100%) rename workflows/bulk-import-git-repos/{ => src/main/resources}/schemas/create-pr-universal-input-schema.json (100%) rename workflows/{experimentals => }/bulk-import-git-repos/src/main/resources/specs/github.yaml (100%) rename workflows/bulk-import-git-repos/{ => src/main/resources}/specs/gitlab.yaml (100%) delete mode 100644 workflows/experimentals/bulk-import-git-repos/README.md delete mode 100644 workflows/experimentals/bulk-import-git-repos/application.properties delete mode 100644 workflows/experimentals/bulk-import-git-repos/argfile.conf delete mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml delete mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml delete mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml delete mode 100755 workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml delete mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json delete mode 100644 workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml diff --git a/.github/workflows/bulk-import-git-repos.yml b/.github/workflows/bulk-import-git-repos.yml index 0c9cd26b..635dceee 100644 --- a/.github/workflows/bulk-import-git-repos.yml +++ b/.github/workflows/bulk-import-git-repos.yml @@ -15,5 +15,5 @@ jobs: bulk-import-git-repos: uses: ./.github/workflows/main.yml with: - workflow_id: experimentals/bulk-import-git-repos + workflow_id: bulk-import-git-repos secrets: inherit diff --git a/Makefile b/Makefile index 237615d4..b52b7de7 100644 --- a/Makefile +++ b/Makefile @@ -86,10 +86,8 @@ else DOCKERFILE ?= src/main/docker/Dockerfile.jvm endif -# For image name strip experimentals/ prefix so image is serverless-workflow-bulk-import-git-repos not serverless-workflow-experimentals/bulk-import-git-repos -WORKFLOW_ID_FOR_IMAGE ?= $(patsubst experimentals/%,%,$(WORKFLOW_ID)) ifeq ($(IS_WORKFLOW),true) -IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(WORKFLOW_ID_FOR_IMAGE) +IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(WORKFLOW_ID) else IMAGE_NAME = $(REGISTRY)/$(REGISTRY_REPO)/$(IMAGE_PREFIX)-$(APPLICATION_ID) endif @@ -168,7 +166,7 @@ save-oci: build-image # Depends on: prepare-workdir target. # Usage: make gen-manifests # Optional: WORKFLOW_SUBDIR โ€” when set, first arg is workflows/$(WORKFLOW_SUBDIR); when unset, workflows/$(WORKFLOW_ID) -# make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=experimentals/bulk-import-git-repos/src/main/resources gen-manifests +# make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests GEN_MANIFESTS_WORKFLOW_FOLDER = workflows/$(if $(WORKFLOW_SUBDIR),$(WORKFLOW_SUBDIR),$(WORKFLOW_ID)) gen-manifests: prepare-workdir @# Ensure WORKDIR exists and is accessible (important for macOS Podman) diff --git a/workflows/bulk-import-git-repos/Makefile b/workflows/bulk-import-git-repos/Makefile deleted file mode 100644 index 98f50ff0..00000000 --- a/workflows/bulk-import-git-repos/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# Makefile for bulk-import-git-repos workflow -# Generates Kubernetes manifests locally - -WORKFLOW_ID := bulk-import-git-repos -WORKFLOW_IMAGE_REGISTRY ?= quay.io -WORKFLOW_IMAGE_NAMESPACE ?= orchestrator -WORKFLOW_IMAGE_REPO ?= serverless-workflow-$(WORKFLOW_ID) -WORKFLOW_IMAGE_TAG ?= latest -CONTAINER_ENGINE ?= $(shell which podman >/dev/null 2>&1 && echo podman || echo docker) -LINUX_IMAGE ?= quay.io/orchestrator/ubi9-pipeline:latest - -.PHONY: gen-manifests clean help - -help: - @echo "Available targets:" - @echo " gen-manifests - Generate Kubernetes manifests" - @echo " clean - Remove generated manifests" - @echo "" - @echo "Variables:" - @echo " WORKFLOW_IMAGE_TAG - Image tag (default: latest)" - @echo " CONTAINER_ENGINE - docker or podman (default: auto-detect)" - -gen-manifests: - @echo "๐Ÿ› ๏ธ Generating manifests for $(WORKFLOW_ID)..." - @$(CONTAINER_ENGINE) run --rm \ - -v $(PWD):/workdir:Z \ - -w /workdir \ - $(LINUX_IMAGE) \ - /bin/bash -c "echo -e '\nkie.flyway.enabled=false' >> application.properties && kn-workflow gen-manifest --profile=gitops --namespace='' --image=$(WORKFLOW_IMAGE_REGISTRY)/$(WORKFLOW_IMAGE_NAMESPACE)/$(WORKFLOW_IMAGE_REPO):$(WORKFLOW_IMAGE_TAG)" - @echo "โœ… Manifests generated in ./manifests/" - -clean: - @echo "๐Ÿงน Cleaning generated manifests..." - @rm -rf manifests/ - @echo "โœ… Cleaned" diff --git a/workflows/bulk-import-git-repos/README.md b/workflows/bulk-import-git-repos/README.md index 32e26d71..ac90d050 100644 --- a/workflows/bulk-import-git-repos/README.md +++ b/workflows/bulk-import-git-repos/README.md @@ -26,3 +26,23 @@ The workflow expects the following input parameters: - For GitHub: Returns PR URL in `PR_URL` output - For GitLab: Returns MR URL in `MR_URL` output + +# Development + +Java artifacts build(prerequisites: pre-installed java and maven): + +``` +mvn clean install +``` + +Generate manifests, from the root of the repository: + +``` +make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests +``` + +Build image: + +``` +make WORKFLOW_ID=bulk-import-git-repos build-image +``` diff --git a/workflows/bulk-import-git-repos/application.properties b/workflows/bulk-import-git-repos/application.properties index 304d1f2e..b97b1c00 100644 --- a/workflows/bulk-import-git-repos/application.properties +++ b/workflows/bulk-import-git-repos/application.properties @@ -1,18 +1,2 @@ -# This property is used to select the log level, which controls the amount -# of information logged on HTTP requests based on the severity of the events. -# Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. -# and see https://quarkus.io/guides/logging for documentation -quarkus.log.category."org.apache.http".level=INFO -quarkus.log.level=INFO - kie.flyway.enabled=false - -%dev.quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true -%dev.quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github - -%dev.quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true -%dev.quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two - -%dev.quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true -%dev.quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab diff --git a/workflows/bulk-import-git-repos/argfile.conf b/workflows/bulk-import-git-repos/argfile.conf index dd7b939e..bfeb7ccc 100644 --- a/workflows/bulk-import-git-repos/argfile.conf +++ b/workflows/bulk-import-git-repos/argfile.conf @@ -1,3 +1,6 @@ -FLOW_NAME=bulk-import-git-repos Serverless Workflow -FLOW_SUMMARY=bulk-import-git-repos Serverless Workflow -FLOW_DESCRIPTION=Workflow for creating pull requests (GitHub) or merge requests (GitLab) based on approvalTool parameter +FLOW_NAME=Universal PR +FLOW_SUMMARY=Create Universal Pull/Merge Request +FLOW_DESCRIPTION=This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. +# Base extensions (JARs included in image): persistence-jdbc, jdbc-postgresql, openapi-generator, oidc-client-filter, oidc, agroal +QUARKUS_EXTENSIONS=org.kie:kie-addons-quarkus-persistence-jdbc,io.quarkus:quarkus-jdbc-postgresql:3.15.4.redhat-00001,io.quarkiverse.openapi.generator:quarkus-openapi-generator:2.9.1-lts,io.quarkus:quarkus-oidc-client-filter,io.quarkus:quarkus-oidc,io.quarkus:quarkus-agroal:3.15.4.redhat-00001,org.kie:kie-addons-quarkus-monitoring-sonataflow,org.kie:kogito-addons-quarkus-jobs-knative-eventing +MAVEN_ARGS_APPEND=-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=postgresql -Dkogito.persistence.proto.marshaller=false diff --git a/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml b/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml deleted file mode 100644 index a28ab86b..00000000 --- a/workflows/bulk-import-git-repos/create-pr-universal.sw.yaml +++ /dev/null @@ -1,294 +0,0 @@ -id: universal-pr -version: "1.0" -specVersion: "0.8" -name: "Create Universal Pull/Merge Request" -description: "This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter." -dataInputSchema: schemas/create-pr-universal-input-schema.json -functions: - # Common functions - - name: scafolderMock - type: expression - operation: | - { - "files": [ - { - "path": "README.md", - "content": "# Hello World" - }, - { - "path": "index.js", - "content": "console.log('Hello, world!');" - } - ] - } - - name: sysLog - type: custom - operation: sysout:INFO - - # GitHub functions - - name: getBranchSHA - operation: specs/github.yaml#getBranchSHA - - name: pushCommitBranch - operation: specs/github.yaml#updateBranchRef - - name: createCommit - operation: specs/github.yaml#createCommit - - name: createTree - operation: specs/github.yaml#createTree - - name: createBlob - operation: specs/github.yaml#createBlob - - name: createBranch - operation: specs/github.yaml#createBranch - - name: getCommitDetails - operation: specs/github.yaml#getCommitDetails - - name: createPullRequest - operation: specs/github.yaml#createPullRequest - - name: createNewBlob - type: expression - operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' - - name: githubSuccessResult - type: expression - operation: '{ - "result": { - "message": "PR created", - "outputs":[ - { - "key": "PR_URL", - "value": .prURL.html_url, - "format":"link" - } - ] - } - }' - - # GitLab functions - - name: searchProjects - operation: specs/gitlab.yaml#searchProjects - - name: getProject - operation: specs/gitlab.yaml#getProject - - name: gitlabCreateBranch - operation: specs/gitlab.yaml#createBranch - - name: gitlabCreateCommit - operation: specs/gitlab.yaml#createCommit - - name: gitlabCreateMergeRequest - operation: specs/gitlab.yaml#createMergeRequest - - name: gitlabSuccessResult - type: expression - operation: '{ - "result": { - "message": "Merge Request created", - "outputs":[ - { - "key": "MR_URL", - "value": .mrURL.web_url, - "format":"link" - } - ] - } - }' - -start: "GetScafolderData" -states: - - name: GetScafolderData - type: operation - actions: - - name: "Get Scafolder data" - functionRef: - refName: scafolderMock - actionDataFilter: - toStateData: .scafolderReponse - transition: RouteToProvider - - - name: RouteToProvider - type: switch - dataConditions: - - condition: '${ .approvalTool == "GIT" }' - transition: GitHubCreateBranch - - condition: '${ .approvalTool == "GITLAB" }' - transition: GitLabSearchProject - defaultCondition: - transition: ErrorUnknownProvider - - - name: ErrorUnknownProvider - type: inject - data: - error: "Unknown or unsupported approval tool" - approvalTool: "${ .approvalTool }" - end: true - - # GitHub workflow states - - name: GitHubCreateBranch - type: operation - actions: - - functionRef: - refName: sysLog - arguments: - message: '${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) }' - - name: "GetHeadSha" - functionRef: - refName: getBranchSHA - arguments: - owner: .owner - repo: .repo - ref: '"heads/" + .baseBranch' - actionDataFilter: - toStateData: .latestSHA - - name: "createBranch" - functionRef: - refName: createBranch - arguments: - owner: .owner - repo: .repo - ref: '"refs/heads/" + .targetBranch' - sha: .latestSHA.object.sha - - name: "getCommitDetails" - functionRef: - refName: getCommitDetails - arguments: - owner: .owner - repo: .repo - commit_sha: .latestSHA.object.sha - actionDataFilter: - toStateData: .commit - transition: GitHubCreateFiles - - - name: GitHubCreateFiles - type: foreach - inputCollection: "${ [.scafolderReponse.files[]] }" - iterationParam: currentFile - outputCollection: .blobs - actions: - - name: "createBlob" - functionRef: - refName: createBlob - arguments: - owner: .owner - repo: .repo - content: ($currentFile.content|tostring) - encoding: "utf-8" - - name: createNewBlob - functionRef: - refName: createNewBlob - transition: GitHubCreateNewTree - - - name: GitHubCreateNewTree - type: operation - actions: - - name: "createTree" - functionRef: - refName: createTree - arguments: - owner: .owner - repo: .repo - base_tree: .commit.tree.sha - tree: .blobs - actionDataFilter: - toStateData: .newTree - - name: "createCommit" - functionRef: - refName: createCommit - arguments: - owner: .owner - repo: .repo - message: "Added/Updated multiple files via API" - tree: .newTree.sha - parents: [.latestSHA.object.sha] - actionDataFilter: - toStateData: .newCommit - - name: "push" - functionRef: - refName: pushCommitBranch - arguments: - owner: .owner - repo: .repo - ref: '"heads/" + .targetBranch' - sha: .newCommit.sha - force: false - transition: GitHubCreatePR - - - name: GitHubCreatePR - type: operation - actions: - - name: "createPullRequest" - functionRef: - refName: createPullRequest - arguments: - owner: .owner - repo: .repo - title: "Automated PR" - body: "" - head: .targetBranch - base: .baseBranch - actionDataFilter: - toStateData: .prURL - - name: setOutput - functionRef: - refName: githubSuccessResult - end: true - - # GitLab workflow states - - name: GitLabSearchProject - type: operation - actions: - - functionRef: - refName: sysLog - arguments: - message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' - - name: SearchProjects - functionRef: - refName: searchProjects - arguments: - search: .repo - membership: true - per_page: 100 - actionDataFilter: - toStateData: .projectsList - stateDataFilter: - output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' - transition: GitLabCreateBranch - - - name: GitLabCreateBranch - type: operation - actions: - - functionRef: - refName: sysLog - arguments: - message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' - - name: "createBranch" - functionRef: - refName: gitlabCreateBranch - arguments: - id: .project.id | tostring - branch: .targetBranch - ref: .baseBranch - transition: GitLabCreateCommit - - - name: GitLabCreateCommit - type: operation - actions: - - name: "createCommit" - functionRef: - refName: gitlabCreateCommit - arguments: - id: .project.id | tostring - branch: .targetBranch - commit_message: "Added/Updated multiple files via API" - actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' - transition: GitLabCreateMR - - - name: GitLabCreateMR - type: operation - actions: - - name: "createMergeRequest" - functionRef: - refName: gitlabCreateMergeRequest - arguments: - id: .project.id | tostring - source_branch: .targetBranch - target_branch: .baseBranch - title: "Automated MR" - actionDataFilter: - toStateData: .mrURL - - name: setOutput - functionRef: - refName: gitlabSuccessResult - end: true diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml b/workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml rename to workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml diff --git a/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml b/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml index 4aac555f..5928ec1c 100755 --- a/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml +++ b/workflows/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml @@ -1,10 +1,40 @@ apiVersion: v1 data: - application.properties: "# This property is used to select the log level, which - controls the amount\n# of information logged on HTTP requests based on the severity - of the events.\n# Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL.\n# - and see https://quarkus.io/guides/logging for documentation\nquarkus.log.category.\"org.apache.http\".level=INFO\nquarkus.log.level=INFO\n\nkie.flyway.enabled=true\n-e - \nkie.flyway.enabled=true\n-e \nkie.flyway.enabled=true\n" + application.properties: | + # This property is used to select the log level, which controls the amount + # of information logged on HTTP requests based on the severity of the events. + # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. + # and see https://quarkus.io/guides/logging for documentation + quarkus.log.category."org.apache.http".level=DEBUG + quarkus.log.level=DEBUG + + # Datasource + quarkus.datasource.db-kind=postgresql + quarkus.datasource.jdbc.url=jdbc:postgresql://postgres.showcase.svc.cluster.local:5432/sonata + quarkus.datasource.username=sonata + quarkus.datasource.password=sonata + + # Persistence + kogito.persistence.type=jdbc + kogito.persistence.auto.ddl=false + kie.flyway.enabled=true + + quarkus.oidc.enabled=false + quarkus.oidc.tenant-enabled=false + quarkus.kogito.devservices.enabled=false + quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true + quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github + # quarkus.rest-client.github_yaml.headers.Accept=application/vnd.github+json + # quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-github + # quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} + + # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true + # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two + + quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true + quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab + + kie.flyway.enabled=true kind: ConfigMap metadata: creationTimestamp: null diff --git a/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml b/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml index fd76282d..21413170 100755 --- a/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml +++ b/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml @@ -13,7 +13,44 @@ data: security: - BearerToken: [] paths: - /repos/{owner}/{repo}/git/ref/{ref}: + /repos/{owner}/{repo}/git/refs/{ref}: + patch: + summary: Update a branch reference + operationId: updateBranchRef + parameters: + - name: owner + in: path + required: true + schema: + type: string + - name: repo + in: path + required: true + schema: + type: string + - name: ref + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + sha: + type: string + force: + type: boolean + responses: + '200': + description: Branch updated successfully + content: + application/json: + schema: + type: object get: summary: Get the SHA of a ref operationId: getBranchSHA @@ -81,44 +118,6 @@ data: application/json: schema: type: object - /repos/{owner}/{repo}/git/refs/{ref}: - patch: - summary: Update a branch reference - operationId: updateBranchRef - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: ref - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - sha: - type: string - force: - type: boolean - responses: - '200': - description: Branch updated successfully - content: - application/json: - schema: - type: object /repos/{owner}/{repo}/git/blobs: post: summary: Create a new blob @@ -152,9 +151,6 @@ data: application/json: schema: type: object - properties: - sha: - type: string /repos/{owner}/{repo}/git/trees: post: summary: Create a new tree @@ -199,9 +195,6 @@ data: application/json: schema: type: object - properties: - sha: - type: string /repos/{owner}/{repo}/git/commits: post: summary: Create a new commit @@ -239,9 +232,6 @@ data: application/json: schema: type: object - properties: - sha: - type: string /repos/{owner}/{repo}/git/commits/{commit_sha}: get: summary: Get details of a commit @@ -269,12 +259,6 @@ data: application/json: schema: type: object - properties: - tree: - type: object - properties: - sha: - type: string /repos/{owner}/{repo}/pulls: post: summary: Create a pull request diff --git a/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml index b7dcefea..d8f45e9e 100755 --- a/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml +++ b/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml @@ -2,8 +2,7 @@ apiVersion: sonataflow.org/v1alpha08 kind: SonataFlow metadata: annotations: - sonataflow.org/description: This workflow creates a pull request (GitHub) or merge - request (GitLab) based on approvalTool parameter. + sonataflow.org/description: This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. sonataflow.org/expressionLang: jq sonataflow.org/profile: gitops sonataflow.org/version: "1.0" @@ -22,360 +21,351 @@ spec: failOnValidationErrors: true schema: schemas/create-pr-universal-input-schema.json functions: - - name: scafolderMock - operation: | - { - "files": [ - { - "path": "README.md", - "content": "# Hello World" - }, - { - "path": "index.js", - "content": "console.log('Hello, world!');" - } - ] - } - type: expression - - name: sysLog - operation: sysout:INFO - type: custom - - name: getBranchSHA - operation: specs/github.yaml#getBranchSHA - type: rest - - name: pushCommitBranch - operation: specs/github.yaml#updateBranchRef - type: rest - - name: createCommit - operation: specs/github.yaml#createCommit - type: rest - - name: createTree - operation: specs/github.yaml#createTree - type: rest - - name: createBlob - operation: specs/github.yaml#createBlob - type: rest - - name: createBranch - operation: specs/github.yaml#createBranch - type: rest - - name: getCommitDetails - operation: specs/github.yaml#getCommitDetails - type: rest - - name: createPullRequest - operation: specs/github.yaml#createPullRequest - type: rest - - name: createNewBlob - operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": - "blob", "sha": $WORKFLOW.prevActionResult.sha}' - type: expression - - name: githubSuccessResult - operation: '{ "result": { "message": "PR created", "outputs":[ { "key": "PR_URL", - "value": .prURL.html_url, "format":"link" } ] } }' - type: expression - - name: searchProjects - operation: specs/gitlab.yaml#searchProjects - type: rest - - name: getProject - operation: specs/gitlab.yaml#getProject - type: rest - - name: gitlabCreateBranch - operation: specs/gitlab.yaml#createBranch - type: rest - - name: gitlabCreateCommit - operation: specs/gitlab.yaml#createCommit - type: rest - - name: gitlabCreateMergeRequest - operation: specs/gitlab.yaml#createMergeRequest - type: rest - - name: gitlabSuccessResult - operation: '{ "result": { "message": "Merge Request created", "outputs":[ { - "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }' - type: expression + - name: scafolderMock + operation: | + { + "files": [ + { + "path": "README.md", + "content": "# Hello World" + }, + { + "path": "index.js", + "content": "console.log('Hello, world!');" + } + ] + } + type: expression + - name: sysLog + operation: sysout:INFO + type: custom + - name: getBranchSHA + operation: specs/github.yaml#getBranchSHA + type: rest + - name: createCommit + operation: specs/github.yaml#createCommit + type: rest + - name: createTree + operation: specs/github.yaml#createTree + type: rest + - name: createBlob + operation: specs/github.yaml#createBlob + type: rest + - name: createBranch + operation: specs/github.yaml#createBranch + type: rest + - name: getCommitDetails + operation: specs/github.yaml#getCommitDetails + type: rest + - name: createPullRequest + operation: specs/github.yaml#createPullRequest + type: rest + - name: createNewBlob + operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' + type: expression + - name: githubSuccessResult + operation: '{ "result": { "message": "PR created", "outputs":[ { "key": "PR_URL", "value": .prURL.html_url, "format":"link" } ] } }' + type: expression + - name: searchProjects + operation: specs/gitlab.yaml#searchProjects + type: rest + - name: getProject + operation: specs/gitlab.yaml#getProject + type: rest + - name: gitlabCreateBranch + operation: specs/gitlab.yaml#createBranch + type: rest + - name: gitlabCreateCommit + operation: specs/gitlab.yaml#createCommit + type: rest + - name: gitlabCreateMergeRequest + operation: specs/gitlab.yaml#createMergeRequest + type: rest + - name: gitlabSuccessResult + operation: '{ "result": { "message": "Merge Request created", "outputs":[ { "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }' + type: expression start: stateName: GetScafolderData states: - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .scafolderReponse - useResults: true - functionRef: - invoke: sync - refName: scafolderMock - name: Get Scafolder data - name: GetScafolderData - transition: - nextState: RouteToProvider - type: operation - - dataConditions: - - condition: ${ .approvalTool == "GIT" } + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .scafolderReponse + useResults: true + functionRef: + invoke: sync + refName: scafolderMock + name: Get Scafolder data + name: GetScafolderData transition: - nextState: GitHubCreateBranch - - condition: ${ .approvalTool == "GITLAB" } + nextState: RouteToProvider + type: operation + - dataConditions: + - condition: ${ .approvalTool == "GIT" } + transition: + nextState: GitHubCreateBranch + - condition: ${ .approvalTool == "GITLAB" } + transition: + nextState: GitLabSearchProject + defaultCondition: + transition: + nextState: ErrorUnknownProvider + name: RouteToProvider + type: switch + - data: + approvalTool: ${ .approvalTool } + error: Unknown or unsupported approval tool + end: + terminate: true + name: ErrorUnknownProvider + type: inject + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: ${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) } + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .latestSHA + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"heads/" + .baseBranch' + repo: .repo + invoke: sync + refName: getBranchSHA + name: GetHeadSha + - actionDataFilter: + toStateData: .commit + useResults: true + functionRef: + arguments: + commit_sha: .latestSHA.object.sha + owner: .owner + repo: .repo + invoke: sync + refName: getCommitDetails + name: getCommitDetails + name: GitHubCreateBranch transition: - nextState: GitLabSearchProject - defaultCondition: + nextState: GitHubCreateFiles + type: operation + - actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + content: ($currentFile.content|tostring) + encoding: utf-8 + owner: .owner + repo: .repo + invoke: sync + refName: createBlob + name: createBlob + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: createNewBlob + name: createNewBlob + inputCollection: ${ [.scafolderReponse.files[]] } + iterationParam: currentFile + mode: parallel + name: GitHubCreateFiles + outputCollection: .blobs transition: - nextState: ErrorUnknownProvider - name: RouteToProvider - type: switch - - data: - approvalTool: ${ .approvalTool } - error: Unknown or unsupported approval tool - end: - terminate: true - name: ErrorUnknownProvider - type: inject - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: ${ "Creating GitHub branch for " + (.owner | tostring) + "/" - + (.repo | tostring) } - invoke: sync - refName: sysLog - - actionDataFilter: - toStateData: .latestSHA - useResults: true - functionRef: - arguments: - owner: .owner - ref: '"heads/" + .baseBranch' - repo: .repo - invoke: sync - refName: getBranchSHA - name: GetHeadSha - - actionDataFilter: - useResults: true - functionRef: - arguments: - owner: .owner - ref: '"refs/heads/" + .targetBranch' - repo: .repo - sha: .latestSHA.object.sha - invoke: sync - refName: createBranch - name: createBranch - - actionDataFilter: - toStateData: .commit - useResults: true - functionRef: - arguments: - commit_sha: .latestSHA.object.sha - owner: .owner - repo: .repo - invoke: sync - refName: getCommitDetails - name: getCommitDetails - name: GitHubCreateBranch - transition: - nextState: GitHubCreateFiles - type: operation - - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - content: ($currentFile.content|tostring) - encoding: utf-8 - owner: .owner - repo: .repo - invoke: sync - refName: createBlob - name: createBlob - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: createNewBlob - name: createNewBlob - inputCollection: ${ [.scafolderReponse.files[]] } - iterationParam: currentFile - mode: parallel - name: GitHubCreateFiles - outputCollection: .blobs - transition: - nextState: GitHubCreateNewTree - type: foreach - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .newTree - useResults: true - functionRef: - arguments: - base_tree: .commit.tree.sha - owner: .owner - repo: .repo - tree: .blobs - invoke: sync - refName: createTree - name: createTree - - actionDataFilter: - toStateData: .newCommit - useResults: true - functionRef: - arguments: - message: Added/Updated multiple files via API - owner: .owner - parents: - - .latestSHA.object.sha - repo: .repo - tree: .newTree.sha - invoke: sync - refName: createCommit - name: createCommit - - actionDataFilter: - useResults: true - functionRef: - arguments: - force: false - owner: .owner - ref: '"heads/" + .targetBranch' - repo: .repo - sha: .newCommit.sha - invoke: sync - refName: pushCommitBranch - name: push - name: GitHubCreateNewTree - transition: - nextState: GitHubCreatePR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .prURL - useResults: true - functionRef: - arguments: - base: .baseBranch - body: "" - head: .targetBranch - owner: .owner - repo: .repo - title: Automated PR - invoke: sync - refName: createPullRequest - name: createPullRequest - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: githubSuccessResult - name: setOutput - end: - terminate: true - name: GitHubCreatePR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" - + (.repo | tostring) }' - invoke: sync - refName: sysLog - - actionDataFilter: - toStateData: .projectsList - useResults: true - functionRef: - arguments: - membership: true - per_page: 100 - search: .repo - invoke: sync - refName: searchProjects - name: SearchProjects - name: GitLabSearchProject - stateDataFilter: - output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace - == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: - $project} }' - transition: - nextState: GitLabCreateBranch - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: '${ "Creating GitLab branch with project ID: " + (.project.id - | tostring) }' - invoke: sync - refName: sysLog - - actionDataFilter: - useResults: true - functionRef: - arguments: - branch: .targetBranch - id: .project.id | tostring - ref: .baseBranch - invoke: sync - refName: gitlabCreateBranch - name: createBranch - name: GitLabCreateBranch - transition: - nextState: GitLabCreateCommit - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": - .path, "content": .content }) }' - branch: .targetBranch - commit_message: Added/Updated multiple files via API - id: .project.id | tostring - invoke: sync - refName: gitlabCreateCommit - name: createCommit - name: GitLabCreateCommit - transition: - nextState: GitLabCreateMR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .mrURL - useResults: true - functionRef: - arguments: - id: .project.id | tostring - source_branch: .targetBranch - target_branch: .baseBranch - title: Automated MR - invoke: sync - refName: gitlabCreateMergeRequest - name: createMergeRequest - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: gitlabSuccessResult - name: setOutput - end: - terminate: true - name: GitLabCreateMR - type: operation + nextState: GitHubCreateNewTree + type: foreach + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .newTree + useResults: true + functionRef: + arguments: + base_tree: .commit.tree.sha + owner: .owner + repo: .repo + tree: .blobs + invoke: sync + refName: createTree + name: createTree + - actionDataFilter: + toStateData: .newCommit + useResults: true + functionRef: + arguments: + message: Added/Updated multiple files via API + owner: .owner + parents: + - .latestSHA.object.sha + repo: .repo + tree: .newTree.sha + invoke: sync + refName: createCommit + name: createCommit + - actionDataFilter: + useResults: true + functionRef: + arguments: + owner: .owner + ref: '"refs/heads/" + .targetBranch' + repo: .repo + sha: .newCommit.sha + invoke: sync + refName: createBranch + name: createBranch + name: GitHubCreateNewTree + transition: + nextState: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .prURL + useResults: true + functionRef: + arguments: + base: .baseBranch + body: "" + head: .targetBranch + owner: .owner + repo: .repo + title: Automated PR + invoke: sync + refName: createPullRequest + name: createPullRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: githubSuccessResult + name: setOutput + end: + terminate: true + name: GitHubCreatePR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + toStateData: .projectsList + useResults: true + functionRef: + arguments: + membership: true + per_page: 100 + search: .repo + invoke: sync + refName: searchProjects + name: SearchProjects + name: GitLabSearchProject + stateDataFilter: + output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' + transition: + nextState: GitLabCreateBranch + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' + invoke: sync + refName: sysLog + - actionDataFilter: + useResults: true + functionRef: + arguments: + branch: .targetBranch + id: .project.id | tostring + ref: .baseBranch + invoke: sync + refName: gitlabCreateBranch + name: createBranch + name: GitLabCreateBranch + transition: + nextState: GitLabCreateCommit + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' + branch: .targetBranch + commit_message: Added/Updated multiple files via API + id: .project.id | tostring + invoke: sync + refName: gitlabCreateCommit + name: createCommit + name: GitLabCreateCommit + transition: + nextState: GitLabCreateMR + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .mrURL + useResults: true + functionRef: + arguments: + id: .project.id | tostring + source_branch: .targetBranch + target_branch: .baseBranch + title: Automated MR + invoke: sync + refName: gitlabCreateMergeRequest + name: createMergeRequest + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: gitlabSuccessResult + name: setOutput + end: + terminate: true + name: GitLabCreateMR + type: operation podTemplate: container: - image: quay.io/orchestrator/serverless-workflow-bulk-import-git-repos:latest + image: quay.io/aandriienko/serverless-workflow-bulk-import-git-repos:de685fb03cf1427157000e206cce22b1dc08d25f resources: {} + envFrom: + - secretRef: + name: gh-pr-secrets resources: configMaps: - - configMap: - name: 01-universal-pr-resources-schemas - workflowPath: schemas - - configMap: - name: 02-universal-pr-resources-specs - workflowPath: specs + - configMap: + name: 01-universal-pr-resources-schemas + workflowPath: schemas + - configMap: + name: 02-universal-pr-resources-specs + workflowPath: specs + persistence: + postgresql: + secretRef: + name: "backstage-psql-secret" + userKey: "POSTGRES_USER" + passwordKey: "POSTGRES_PASSWORD" + serviceRef: + name: "backstage-psql" + port: 5432 + databaseName: "backstage_plugin_orchestrator" + databaseSchema: bulk-import-git-repos + namespace: "orchestrator" status: address: {} lastTimeRecoverAttempt: null diff --git a/workflows/experimentals/bulk-import-git-repos/pom.xml b/workflows/bulk-import-git-repos/pom.xml similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/pom.xml rename to workflows/bulk-import-git-repos/pom.xml diff --git a/workflows/bulk-import-git-repos/specs/github.yaml b/workflows/bulk-import-git-repos/specs/github.yaml deleted file mode 100644 index fa2b4839..00000000 --- a/workflows/bulk-import-git-repos/specs/github.yaml +++ /dev/null @@ -1,328 +0,0 @@ -openapi: 3.0.0 -info: - title: GitHub Repository Automation API - version: 1.0.0 - description: API specification for automating GitHub repository tasks using the GitHub REST API v3. - -servers: - - url: https://api.github.com - description: GitHub API -security: -- BearerToken: [] -paths: - /repos/{owner}/{repo}/git/ref/{ref}: - get: - summary: Get the SHA of a ref - operationId: getBranchSHA - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: ref - in: path - required: true - schema: - type: string - responses: - '200': - description: Successfully retrieved branch reference - content: - application/json: - schema: - type: object - properties: - object: - type: object - properties: - sha: - type: string - '404': - description: Branch not found - /repos/{owner}/{repo}/git/refs: - post: - summary: Create a new branch - operationId: createBranch - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - ref: - type: string - sha: - type: string - responses: - '201': - description: Branch created successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/refs/{ref}: - patch: - summary: Update a branch reference - operationId: updateBranchRef - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: ref - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - sha: - type: string - force: - type: boolean - responses: - '200': - description: Branch updated successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/blobs: - post: - summary: Create a new blob - operationId: createBlob - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - content: - type: string - encoding: - type: string - responses: - '201': - description: Blob created successfully - content: - application/json: - schema: - type: object - properties: - sha: - type: string - /repos/{owner}/{repo}/git/trees: - post: - summary: Create a new tree - operationId: createTree - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - base_tree: - type: string - tree: - type: array - items: - type: object - properties: - path: - type: string - mode: - type: string - type: - type: string - sha: - type: string - responses: - '201': - description: Tree created successfully - content: - application/json: - schema: - type: object - properties: - sha: - type: string - /repos/{owner}/{repo}/git/commits: - post: - summary: Create a new commit - operationId: createCommit - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - message: - type: string - tree: - type: string - parents: - type: array - items: - type: string - responses: - '201': - description: Commit created successfully - content: - application/json: - schema: - type: object - properties: - sha: - type: string - /repos/{owner}/{repo}/git/commits/{commit_sha}: - get: - summary: Get details of a commit - operationId: getCommitDetails - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: commit_sha - in: path - required: true - schema: - type: string - responses: - '200': - description: Commit details retrieved successfully - content: - application/json: - schema: - type: object - properties: - tree: - type: object - properties: - sha: - type: string - /repos/{owner}/{repo}/pulls: - post: - summary: Create a pull request - description: Opens a new pull request from a branch to the base branch. - operationId: createPullRequest - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - title: - type: string - example: "New Feature: Added new file" - body: - type: string - example: "This PR adds a new file using the GitHub REST API." - head: - type: string - example: "new-feature-branch" - base: - type: string - example: "main" - responses: - '201': - description: Pull request created successfully. - content: - application/json: - schema: - type: object - properties: - html_url: - type: string - example: "https://github.com/user/repo/pull/42" - '422': - description: Invalid input or pull request already exists. -components: - securitySchemes: - BearerToken: - type: http - scheme: bearer - description: Bearer Token authentication diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm b/workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/src/main/docker/Dockerfile.jvm rename to workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties b/workflows/bulk-import-git-repos/src/main/resources/application.properties similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/src/main/resources/application.properties rename to workflows/bulk-import-git-repos/src/main/resources/application.properties diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml b/workflows/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml rename to workflows/bulk-import-git-repos/src/main/resources/create-pr-universal.sw.yaml diff --git a/workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json b/workflows/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json similarity index 100% rename from workflows/bulk-import-git-repos/schemas/create-pr-universal-input-schema.json rename to workflows/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml b/workflows/bulk-import-git-repos/src/main/resources/specs/github.yaml similarity index 100% rename from workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/github.yaml rename to workflows/bulk-import-git-repos/src/main/resources/specs/github.yaml diff --git a/workflows/bulk-import-git-repos/specs/gitlab.yaml b/workflows/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml similarity index 100% rename from workflows/bulk-import-git-repos/specs/gitlab.yaml rename to workflows/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml diff --git a/workflows/experimentals/bulk-import-git-repos/README.md b/workflows/experimentals/bulk-import-git-repos/README.md deleted file mode 100644 index d8af3a19..00000000 --- a/workflows/experimentals/bulk-import-git-repos/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Bulk Import Git Repos Workflow - -This workflow creates pull requests (GitHub) or merge requests (GitLab) based on the `approvalTool` parameter. - -## Overview - -The workflow supports both GitHub and GitLab repositories and can create PRs/MRs with multiple files. - -## Input Schema - -The workflow expects the following input parameters: -- `approvalTool`: Either "GIT" for GitHub or "GITLAB" for GitLab -- `owner`: The owner/namespace of the repository -- `repo`: The repository name -- `baseBranch`: The base branch to create the PR/MR from -- `targetBranch`: The target branch name for the PR/MR - -## Workflow Steps - -1. **GetScafolderData**: Retrieves mock data with files to be added -2. **RouteToProvider**: Routes to either GitHub or GitLab workflow based on `approvalTool` -3. **GitHub Flow**: Creates branch, commits files, and creates a pull request -4. **GitLab Flow**: Searches for project, creates branch, commits files, and creates a merge request - -## Output - -- For GitHub: Returns PR URL in `PR_URL` output -- For GitLab: Returns MR URL in `MR_URL` output - -# Development - -Java artifacts build(prerequisites: pre-installed java and maven): - -``` -mvn clean install -``` - -Generate manifests, from the root of the repository: - -``` -make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=experimentals/bulk-import-git-repos/src/main/resources gen-manifests -``` - -Build image: - -``` -make WORKFLOW_ID=experimentals/bulk-import-git-repos build-image -``` diff --git a/workflows/experimentals/bulk-import-git-repos/application.properties b/workflows/experimentals/bulk-import-git-repos/application.properties deleted file mode 100644 index b97b1c00..00000000 --- a/workflows/experimentals/bulk-import-git-repos/application.properties +++ /dev/null @@ -1,2 +0,0 @@ - -kie.flyway.enabled=false diff --git a/workflows/experimentals/bulk-import-git-repos/argfile.conf b/workflows/experimentals/bulk-import-git-repos/argfile.conf deleted file mode 100644 index bfeb7ccc..00000000 --- a/workflows/experimentals/bulk-import-git-repos/argfile.conf +++ /dev/null @@ -1,6 +0,0 @@ -FLOW_NAME=Universal PR -FLOW_SUMMARY=Create Universal Pull/Merge Request -FLOW_DESCRIPTION=This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. -# Base extensions (JARs included in image): persistence-jdbc, jdbc-postgresql, openapi-generator, oidc-client-filter, oidc, agroal -QUARKUS_EXTENSIONS=org.kie:kie-addons-quarkus-persistence-jdbc,io.quarkus:quarkus-jdbc-postgresql:3.15.4.redhat-00001,io.quarkiverse.openapi.generator:quarkus-openapi-generator:2.9.1-lts,io.quarkus:quarkus-oidc-client-filter,io.quarkus:quarkus-oidc,io.quarkus:quarkus-agroal:3.15.4.redhat-00001,org.kie:kie-addons-quarkus-monitoring-sonataflow,org.kie:kogito-addons-quarkus-jobs-knative-eventing -MAVEN_ARGS_APPEND=-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=postgresql -Dkogito.persistence.proto.marshaller=false diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml deleted file mode 100755 index 5928ec1c..00000000 --- a/workflows/experimentals/bulk-import-git-repos/manifests/01-configmap_universal-pr-props.yaml +++ /dev/null @@ -1,48 +0,0 @@ -apiVersion: v1 -data: - application.properties: | - # This property is used to select the log level, which controls the amount - # of information logged on HTTP requests based on the severity of the events. - # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. - # and see https://quarkus.io/guides/logging for documentation - quarkus.log.category."org.apache.http".level=DEBUG - quarkus.log.level=DEBUG - - # Datasource - quarkus.datasource.db-kind=postgresql - quarkus.datasource.jdbc.url=jdbc:postgresql://postgres.showcase.svc.cluster.local:5432/sonata - quarkus.datasource.username=sonata - quarkus.datasource.password=sonata - - # Persistence - kogito.persistence.type=jdbc - kogito.persistence.auto.ddl=false - kie.flyway.enabled=true - - quarkus.oidc.enabled=false - quarkus.oidc.tenant-enabled=false - quarkus.kogito.devservices.enabled=false - quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true - quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github - # quarkus.rest-client.github_yaml.headers.Accept=application/vnd.github+json - # quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-github - # quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} - - # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.token-propagation=true - # quarkus.openapi-generator.githubtwo_yaml.auth.BearerToken.header-name=X-Authorization-github-two - - quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.token-propagation=true - quarkus.openapi-generator.gitlab_yaml.auth.BearerToken.header-name=X-Authorization-gitlab - - kie.flyway.enabled=true -kind: ConfigMap -metadata: - creationTimestamp: null - labels: - app: universal-pr - app.kubernetes.io/component: serverless-workflow - app.kubernetes.io/managed-by: sonataflow-operator - app.kubernetes.io/name: universal-pr - sonataflow.org/workflow-app: universal-pr - sonataflow.org/workflow-namespace: "" - name: universal-pr-props diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml deleted file mode 100755 index e1bc69b9..00000000 --- a/workflows/experimentals/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml +++ /dev/null @@ -1,48 +0,0 @@ -apiVersion: v1 -data: - create-pr-universal-input-schema.json: | - { - "$id": "classpath:/schemas/create-pr-universal-input-schema.json", - "title": "Create Universal PR/MR Input Schema", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "approvalTool": { - "title": "Approval Tool", - "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", - "type": "string", - "enum": ["GIT", "GITLAB"] - }, - "owner": { - "title": "Owner", - "description": "The owner/namespace of the repository", - "type": "string" - }, - "repo": { - "title": "Repository", - "description": "The repository name", - "type": "string" - }, - "baseBranch": { - "title": "Base Branch", - "description": "The base branch to create the PR/MR from", - "type": "string" - }, - "targetBranch": { - "title": "Target Branch", - "description": "The target branch name for the PR/MR", - "type": "string" - } - }, - "required": [ - "approvalTool", - "owner", - "repo", - "baseBranch", - "targetBranch" - ] - } -kind: ConfigMap -metadata: - creationTimestamp: null - name: 01-universal-pr-resources-schemas diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml deleted file mode 100755 index 21413170..00000000 --- a/workflows/experimentals/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml +++ /dev/null @@ -1,494 +0,0 @@ -apiVersion: v1 -data: - github.yaml: | - openapi: 3.0.0 - info: - title: GitHub Repository Automation API - version: 1.0.0 - description: API specification for automating GitHub repository tasks using the GitHub REST API v3. - - servers: - - url: https://api.github.com - description: GitHub API - security: - - BearerToken: [] - paths: - /repos/{owner}/{repo}/git/refs/{ref}: - patch: - summary: Update a branch reference - operationId: updateBranchRef - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: ref - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - sha: - type: string - force: - type: boolean - responses: - '200': - description: Branch updated successfully - content: - application/json: - schema: - type: object - get: - summary: Get the SHA of a ref - operationId: getBranchSHA - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: ref - in: path - required: true - schema: - type: string - responses: - '200': - description: Successfully retrieved branch reference - content: - application/json: - schema: - type: object - properties: - object: - type: object - properties: - sha: - type: string - '404': - description: Branch not found - /repos/{owner}/{repo}/git/refs: - post: - summary: Create a new branch - operationId: createBranch - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - ref: - type: string - sha: - type: string - responses: - '201': - description: Branch created successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/blobs: - post: - summary: Create a new blob - operationId: createBlob - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - content: - type: string - encoding: - type: string - responses: - '201': - description: Blob created successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/trees: - post: - summary: Create a new tree - operationId: createTree - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - base_tree: - type: string - tree: - type: array - items: - type: object - properties: - path: - type: string - mode: - type: string - type: - type: string - sha: - type: string - responses: - '201': - description: Tree created successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/commits: - post: - summary: Create a new commit - operationId: createCommit - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - message: - type: string - tree: - type: string - parents: - type: array - items: - type: string - responses: - '201': - description: Commit created successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/git/commits/{commit_sha}: - get: - summary: Get details of a commit - operationId: getCommitDetails - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - - name: commit_sha - in: path - required: true - schema: - type: string - responses: - '200': - description: Commit details retrieved successfully - content: - application/json: - schema: - type: object - /repos/{owner}/{repo}/pulls: - post: - summary: Create a pull request - description: Opens a new pull request from a branch to the base branch. - operationId: createPullRequest - parameters: - - name: owner - in: path - required: true - schema: - type: string - - name: repo - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - title: - type: string - example: "New Feature: Added new file" - body: - type: string - example: "This PR adds a new file using the GitHub REST API." - head: - type: string - example: "new-feature-branch" - base: - type: string - example: "main" - responses: - '201': - description: Pull request created successfully. - content: - application/json: - schema: - type: object - properties: - html_url: - type: string - example: "https://github.com/user/repo/pull/42" - '422': - description: Invalid input or pull request already exists. - components: - securitySchemes: - BearerToken: - type: http - scheme: bearer - description: Bearer Token authentication - gitlab.yaml: | - openapi: 3.0.0 - info: - title: GitLab Repository Automation API - version: 1.0.0 - description: API specification for automating GitLab repository tasks using the GitLab REST API v4. - - servers: - - url: https://gitlab.com/api/v4 - description: GitLab API - security: - - BearerToken: [] - paths: - /projects: - get: - summary: Search for projects - operationId: searchProjects - parameters: - - name: search - in: query - required: false - schema: - type: string - - name: membership - in: query - required: false - schema: - type: boolean - - name: per_page - in: query - required: false - schema: - type: integer - responses: - '200': - description: Successfully retrieved projects - content: - application/json: - schema: - type: array - items: - type: object - properties: - id: - type: integer - path_with_namespace: - type: string - /projects/{id}: - get: - summary: Get project details - operationId: getProject - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Successfully retrieved project - content: - application/json: - schema: - type: object - properties: - id: - type: integer - path_with_namespace: - type: string - /projects/{id}/repository/branches: - post: - summary: Create a new branch - operationId: createBranch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - branch: - type: string - ref: - type: string - responses: - '201': - description: Branch created successfully - content: - application/json: - schema: - type: object - /projects/{id}/repository/commits: - post: - summary: Create a new commit - operationId: createCommit - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - branch: - type: string - commit_message: - type: string - actions: - type: array - items: - type: object - properties: - action: - type: string - file_path: - type: string - content: - type: string - responses: - '201': - description: Commit created successfully - content: - application/json: - schema: - type: object - /projects/{id}/merge_requests: - post: - summary: Create a merge request - operationId: createMergeRequest - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - source_branch: - type: string - target_branch: - type: string - title: - type: string - responses: - '201': - description: Merge request created successfully - content: - application/json: - schema: - type: object - properties: - web_url: - type: string - components: - securitySchemes: - BearerToken: - type: http - scheme: bearer - description: Bearer Token authentication -kind: ConfigMap -metadata: - creationTimestamp: null - name: 02-universal-pr-resources-specs diff --git a/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml deleted file mode 100755 index ef17aabd..00000000 --- a/workflows/experimentals/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml +++ /dev/null @@ -1,371 +0,0 @@ -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlow -metadata: - annotations: - sonataflow.org/description: This workflow creates a pull request (GitHub) or merge request (GitLab) based on approvalTool parameter. - sonataflow.org/expressionLang: jq - sonataflow.org/profile: gitops - sonataflow.org/version: "1.0" - creationTimestamp: null - labels: - app: universal-pr - app.kubernetes.io/component: serverless-workflow - app.kubernetes.io/managed-by: sonataflow-operator - app.kubernetes.io/name: universal-pr - sonataflow.org/workflow-app: universal-pr - sonataflow.org/workflow-namespace: "" - name: universal-pr -spec: - flow: - dataInputSchema: - failOnValidationErrors: true - schema: schemas/create-pr-universal-input-schema.json - functions: - - name: scafolderMock - operation: | - { - "files": [ - { - "path": "README.md", - "content": "# Hello World" - }, - { - "path": "index.js", - "content": "console.log('Hello, world!');" - } - ] - } - type: expression - - name: sysLog - operation: sysout:INFO - type: custom - - name: getBranchSHA - operation: specs/github.yaml#getBranchSHA - type: rest - - name: createCommit - operation: specs/github.yaml#createCommit - type: rest - - name: createTree - operation: specs/github.yaml#createTree - type: rest - - name: createBlob - operation: specs/github.yaml#createBlob - type: rest - - name: createBranch - operation: specs/github.yaml#createBranch - type: rest - - name: getCommitDetails - operation: specs/github.yaml#getCommitDetails - type: rest - - name: createPullRequest - operation: specs/github.yaml#createPullRequest - type: rest - - name: createNewBlob - operation: '{"mode": "100644", "path": ($currentFile.path|tostring), "type": "blob", "sha": $WORKFLOW.prevActionResult.sha}' - type: expression - - name: githubSuccessResult - operation: '{ "result": { "message": "PR created", "outputs":[ { "key": "PR_URL", "value": .prURL.html_url, "format":"link" } ] } }' - type: expression - - name: searchProjects - operation: specs/gitlab.yaml#searchProjects - type: rest - - name: getProject - operation: specs/gitlab.yaml#getProject - type: rest - - name: gitlabCreateBranch - operation: specs/gitlab.yaml#createBranch - type: rest - - name: gitlabCreateCommit - operation: specs/gitlab.yaml#createCommit - type: rest - - name: gitlabCreateMergeRequest - operation: specs/gitlab.yaml#createMergeRequest - type: rest - - name: gitlabSuccessResult - operation: '{ "result": { "message": "Merge Request created", "outputs":[ { "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }' - type: expression - start: - stateName: GetScafolderData - states: - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .scafolderReponse - useResults: true - functionRef: - invoke: sync - refName: scafolderMock - name: Get Scafolder data - name: GetScafolderData - transition: - nextState: RouteToProvider - type: operation - - dataConditions: - - condition: ${ .approvalTool == "GIT" } - transition: - nextState: GitHubCreateBranch - - condition: ${ .approvalTool == "GITLAB" } - transition: - nextState: GitLabSearchProject - defaultCondition: - transition: - nextState: ErrorUnknownProvider - name: RouteToProvider - type: switch - - data: - approvalTool: ${ .approvalTool } - error: Unknown or unsupported approval tool - end: - terminate: true - name: ErrorUnknownProvider - type: inject - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: ${ "Creating GitHub branch for " + (.owner | tostring) + "/" + (.repo | tostring) } - invoke: sync - refName: sysLog - - actionDataFilter: - toStateData: .latestSHA - useResults: true - functionRef: - arguments: - owner: .owner - ref: '"heads/" + .baseBranch' - repo: .repo - invoke: sync - refName: getBranchSHA - name: GetHeadSha - - actionDataFilter: - toStateData: .commit - useResults: true - functionRef: - arguments: - commit_sha: .latestSHA.object.sha - owner: .owner - repo: .repo - invoke: sync - refName: getCommitDetails - name: getCommitDetails - name: GitHubCreateBranch - transition: - nextState: GitHubCreateFiles - type: operation - - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - content: ($currentFile.content|tostring) - encoding: utf-8 - owner: .owner - repo: .repo - invoke: sync - refName: createBlob - name: createBlob - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: createNewBlob - name: createNewBlob - inputCollection: ${ [.scafolderReponse.files[]] } - iterationParam: currentFile - mode: parallel - name: GitHubCreateFiles - outputCollection: .blobs - transition: - nextState: GitHubCreateNewTree - type: foreach - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .newTree - useResults: true - functionRef: - arguments: - base_tree: .commit.tree.sha - owner: .owner - repo: .repo - tree: .blobs - invoke: sync - refName: createTree - name: createTree - - actionDataFilter: - toStateData: .newCommit - useResults: true - functionRef: - arguments: - message: Added/Updated multiple files via API - owner: .owner - parents: - - .latestSHA.object.sha - repo: .repo - tree: .newTree.sha - invoke: sync - refName: createCommit - name: createCommit - - actionDataFilter: - useResults: true - functionRef: - arguments: - owner: .owner - ref: '"refs/heads/" + .targetBranch' - repo: .repo - sha: .newCommit.sha - invoke: sync - refName: createBranch - name: createBranch - name: GitHubCreateNewTree - transition: - nextState: GitHubCreatePR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .prURL - useResults: true - functionRef: - arguments: - base: .baseBranch - body: "" - head: .targetBranch - owner: .owner - repo: .repo - title: Automated PR - invoke: sync - refName: createPullRequest - name: createPullRequest - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: githubSuccessResult - name: setOutput - end: - terminate: true - name: GitHubCreatePR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: '${ "Searching GitLab project: " + (.owner | tostring) + "/" + (.repo | tostring) }' - invoke: sync - refName: sysLog - - actionDataFilter: - toStateData: .projectsList - useResults: true - functionRef: - arguments: - membership: true - per_page: 100 - search: .repo - invoke: sync - refName: searchProjects - name: SearchProjects - name: GitLabSearchProject - stateDataFilter: - output: '${ . as $state | ($state.projectsList // []) | map(select(.path_with_namespace == ($state.owner + "/" + $state.repo)))[0] as $project | $state + {project: $project} }' - transition: - nextState: GitLabCreateBranch - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - message: '${ "Creating GitLab branch with project ID: " + (.project.id | tostring) }' - invoke: sync - refName: sysLog - - actionDataFilter: - useResults: true - functionRef: - arguments: - branch: .targetBranch - id: .project.id | tostring - ref: .baseBranch - invoke: sync - refName: gitlabCreateBranch - name: createBranch - name: GitLabCreateBranch - transition: - nextState: GitLabCreateCommit - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - useResults: true - functionRef: - arguments: - actions: '${ .scafolderReponse.files | map({ "action": "create", "file_path": .path, "content": .content }) }' - branch: .targetBranch - commit_message: Added/Updated multiple files via API - id: .project.id | tostring - invoke: sync - refName: gitlabCreateCommit - name: createCommit - name: GitLabCreateCommit - transition: - nextState: GitLabCreateMR - type: operation - - actionMode: sequential - actions: - - actionDataFilter: - toStateData: .mrURL - useResults: true - functionRef: - arguments: - id: .project.id | tostring - source_branch: .targetBranch - target_branch: .baseBranch - title: Automated MR - invoke: sync - refName: gitlabCreateMergeRequest - name: createMergeRequest - - actionDataFilter: - useResults: true - functionRef: - invoke: sync - refName: gitlabSuccessResult - name: setOutput - end: - terminate: true - name: GitLabCreateMR - type: operation - podTemplate: - container: - image: quay.io/aandriienko/serverless-workflow-bulk-import-git-repos:latest - resources: {} - envFrom: - - secretRef: - name: gh-pr-secrets - resources: - configMaps: - - configMap: - name: 01-universal-pr-resources-schemas - workflowPath: schemas - - configMap: - name: 02-universal-pr-resources-specs - workflowPath: specs - persistence: - postgresql: - secretRef: - name: "backstage-psql-secret" - userKey: "POSTGRES_USER" - passwordKey: "POSTGRES_PASSWORD" - serviceRef: - name: "backstage-psql" - port: 5432 - databaseName: "backstage_plugin_orchestrator" - databaseSchema: bulk-import-git-repos - namespace: "orchestrator" -status: - address: {} - lastTimeRecoverAttempt: null diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json b/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json deleted file mode 100644 index 93a0b5ac..00000000 --- a/workflows/experimentals/bulk-import-git-repos/src/main/resources/schemas/create-pr-universal-input-schema.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "$id": "classpath:/schemas/create-pr-universal-input-schema.json", - "title": "Create Universal PR/MR Input Schema", - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "approvalTool": { - "title": "Approval Tool", - "description": "The Git provider to use: GIT for GitHub or GITLAB for GitLab", - "type": "string", - "enum": ["GIT", "GITLAB"] - }, - "owner": { - "title": "Owner", - "description": "The owner/namespace of the repository", - "type": "string" - }, - "repo": { - "title": "Repository", - "description": "The repository name", - "type": "string" - }, - "baseBranch": { - "title": "Base Branch", - "description": "The base branch to create the PR/MR from", - "type": "string" - }, - "targetBranch": { - "title": "Target Branch", - "description": "The target branch name for the PR/MR", - "type": "string" - } - }, - "required": [ - "approvalTool", - "owner", - "repo", - "baseBranch", - "targetBranch" - ] -} diff --git a/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml b/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml deleted file mode 100644 index e620d77e..00000000 --- a/workflows/experimentals/bulk-import-git-repos/src/main/resources/specs/gitlab.yaml +++ /dev/null @@ -1,174 +0,0 @@ -openapi: 3.0.0 -info: - title: GitLab Repository Automation API - version: 1.0.0 - description: API specification for automating GitLab repository tasks using the GitLab REST API v4. - -servers: - - url: https://gitlab.com/api/v4 - description: GitLab API -security: -- BearerToken: [] -paths: - /projects: - get: - summary: Search for projects - operationId: searchProjects - parameters: - - name: search - in: query - required: false - schema: - type: string - - name: membership - in: query - required: false - schema: - type: boolean - - name: per_page - in: query - required: false - schema: - type: integer - responses: - '200': - description: Successfully retrieved projects - content: - application/json: - schema: - type: array - items: - type: object - properties: - id: - type: integer - path_with_namespace: - type: string - /projects/{id}: - get: - summary: Get project details - operationId: getProject - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - '200': - description: Successfully retrieved project - content: - application/json: - schema: - type: object - properties: - id: - type: integer - path_with_namespace: - type: string - /projects/{id}/repository/branches: - post: - summary: Create a new branch - operationId: createBranch - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - branch: - type: string - ref: - type: string - responses: - '201': - description: Branch created successfully - content: - application/json: - schema: - type: object - /projects/{id}/repository/commits: - post: - summary: Create a new commit - operationId: createCommit - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - branch: - type: string - commit_message: - type: string - actions: - type: array - items: - type: object - properties: - action: - type: string - file_path: - type: string - content: - type: string - responses: - '201': - description: Commit created successfully - content: - application/json: - schema: - type: object - /projects/{id}/merge_requests: - post: - summary: Create a merge request - operationId: createMergeRequest - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - source_branch: - type: string - target_branch: - type: string - title: - type: string - responses: - '201': - description: Merge request created successfully - content: - application/json: - schema: - type: object - properties: - web_url: - type: string -components: - securitySchemes: - BearerToken: - type: http - scheme: bearer - description: Bearer Token authentication From 68ece98053f31e207edd98b8cd112087317f3054 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 14:56:31 +0200 Subject: [PATCH 10/14] feat(rbac): auto generate secret Signed-off-by: Oleksandr Andriienko --- workflows/bulk-import-git-repos/README.md | 3 ++- .../application.properties | 2 +- .../manifests/00-secret_gh-pr-secrets.yaml | 8 ------- .../02-secret_universal-pr-secrets.yaml | 14 +++++++++++ ...ap_01-universal-pr-resources-schemas.yaml} | 0 ...gmap_02-universal-pr-resources-specs.yaml} | 0 ...r.yaml => 05-sonataflow_universal-pr.yaml} | 23 +++++++++++-------- .../src/main/resources/secret.properties | 1 + 8 files changed, 31 insertions(+), 20 deletions(-) delete mode 100644 workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml create mode 100755 workflows/bulk-import-git-repos/manifests/02-secret_universal-pr-secrets.yaml rename workflows/bulk-import-git-repos/manifests/{02-configmap_01-universal-pr-resources-schemas.yaml => 03-configmap_01-universal-pr-resources-schemas.yaml} (100%) rename workflows/bulk-import-git-repos/manifests/{03-configmap_02-universal-pr-resources-specs.yaml => 04-configmap_02-universal-pr-resources-specs.yaml} (100%) rename workflows/bulk-import-git-repos/manifests/{04-sonataflow_universal-pr.yaml => 05-sonataflow_universal-pr.yaml} (96%) create mode 100644 workflows/bulk-import-git-repos/src/main/resources/secret.properties diff --git a/workflows/bulk-import-git-repos/README.md b/workflows/bulk-import-git-repos/README.md index ac90d050..2032f642 100644 --- a/workflows/bulk-import-git-repos/README.md +++ b/workflows/bulk-import-git-repos/README.md @@ -38,7 +38,8 @@ mvn clean install Generate manifests, from the root of the repository: ``` -make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests +make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests \ +cp -rf /tmp/serverless-workflows/workflows/bulk-import-git-repos/src/main/resources/manifests ./workflows/bulk-import-git-repos ``` Build image: diff --git a/workflows/bulk-import-git-repos/application.properties b/workflows/bulk-import-git-repos/application.properties index b97b1c00..6292630b 100644 --- a/workflows/bulk-import-git-repos/application.properties +++ b/workflows/bulk-import-git-repos/application.properties @@ -1,2 +1,2 @@ -kie.flyway.enabled=false +kie.flyway.enabled=true diff --git a/workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml b/workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml deleted file mode 100644 index e397fa92..00000000 --- a/workflows/bulk-import-git-repos/manifests/00-secret_gh-pr-secrets.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -data: - ghToken: Z2hwX0FCQzEyMw== -kind: Secret -type: Opaque -metadata: - creationTimestamp: null - name: gh-pr-secrets diff --git a/workflows/bulk-import-git-repos/manifests/02-secret_universal-pr-secrets.yaml b/workflows/bulk-import-git-repos/manifests/02-secret_universal-pr-secrets.yaml new file mode 100755 index 00000000..ba7b346b --- /dev/null +++ b/workflows/bulk-import-git-repos/manifests/02-secret_universal-pr-secrets.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + creationTimestamp: null + labels: + app: universal-pr + app.kubernetes.io/component: serverless-workflow + app.kubernetes.io/managed-by: sonataflow-operator + app.kubernetes.io/name: universal-pr + sonataflow.org/workflow-app: universal-pr + sonataflow.org/workflow-namespace: "" + name: universal-pr-secrets +stringData: + ghToken: ghp_ABC123 diff --git a/workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml b/workflows/bulk-import-git-repos/manifests/03-configmap_01-universal-pr-resources-schemas.yaml similarity index 100% rename from workflows/bulk-import-git-repos/manifests/02-configmap_01-universal-pr-resources-schemas.yaml rename to workflows/bulk-import-git-repos/manifests/03-configmap_01-universal-pr-resources-schemas.yaml diff --git a/workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml b/workflows/bulk-import-git-repos/manifests/04-configmap_02-universal-pr-resources-specs.yaml similarity index 100% rename from workflows/bulk-import-git-repos/manifests/03-configmap_02-universal-pr-resources-specs.yaml rename to workflows/bulk-import-git-repos/manifests/04-configmap_02-universal-pr-resources-specs.yaml diff --git a/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml b/workflows/bulk-import-git-repos/manifests/05-sonataflow_universal-pr.yaml similarity index 96% rename from workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml rename to workflows/bulk-import-git-repos/manifests/05-sonataflow_universal-pr.yaml index d8f45e9e..634105dd 100755 --- a/workflows/bulk-import-git-repos/manifests/04-sonataflow_universal-pr.yaml +++ b/workflows/bulk-import-git-repos/manifests/05-sonataflow_universal-pr.yaml @@ -341,11 +341,14 @@ spec: type: operation podTemplate: container: - image: quay.io/aandriienko/serverless-workflow-bulk-import-git-repos:de685fb03cf1427157000e206cce22b1dc08d25f + env: + - name: GHTOKEN + valueFrom: + secretKeyRef: + key: ghToken + name: universal-pr-secrets + image: quay.io/aandriienko/serverless-workflow-bulk-import-git-repos:latest resources: {} - envFrom: - - secretRef: - name: gh-pr-secrets resources: configMaps: - configMap: @@ -357,15 +360,15 @@ spec: persistence: postgresql: secretRef: - name: "backstage-psql-secret" - userKey: "POSTGRES_USER" - passwordKey: "POSTGRES_PASSWORD" + name: backstage-psql-secret + userKey: POSTGRES_USER + passwordKey: POSTGRES_PASSWORD serviceRef: - name: "backstage-psql" + name: backstage-psql port: 5432 - databaseName: "backstage_plugin_orchestrator" + databaseName: backstage_plugin_orchestrator databaseSchema: bulk-import-git-repos - namespace: "orchestrator" + namespace: orchestrator status: address: {} lastTimeRecoverAttempt: null diff --git a/workflows/bulk-import-git-repos/src/main/resources/secret.properties b/workflows/bulk-import-git-repos/src/main/resources/secret.properties new file mode 100644 index 00000000..4a977c3f --- /dev/null +++ b/workflows/bulk-import-git-repos/src/main/resources/secret.properties @@ -0,0 +1 @@ +ghToken=ghp_ABC123 From e313e4b4ab5b7af202ca32adfa2d50e7a57968f9 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 15:28:47 +0200 Subject: [PATCH 11/14] cleanup Signed-off-by: Oleksandr Andriienko --- commands.env | 0 pipeline/workflow-builder.Dockerfile | 8 ++------ scripts/gen_manifests.sh | 5 +---- workflows/bulk-import-git-repos/README.md | 2 +- .../github-pr/manifests/04-sonataflow_gh-pr.yaml | 12 ++++++------ .../src/main/resources/application.properties | 3 +-- 6 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 commands.env diff --git a/commands.env b/commands.env deleted file mode 100644 index e69de29b..00000000 diff --git a/pipeline/workflow-builder.Dockerfile b/pipeline/workflow-builder.Dockerfile index 0d1191b4..818e7b8e 100644 --- a/pipeline/workflow-builder.Dockerfile +++ b/pipeline/workflow-builder.Dockerfile @@ -33,10 +33,6 @@ ARG QUARKUS_EXTENSIONS=io.quarkiverse.openapi.generator:quarkus-openapi-generato # YAML input files, and is currently set to 35000000 characters (~33MB in UTF-8). ARG MAVEN_ARGS_APPEND="-DmaxYamlCodePoints=35000000 -Dkogito.persistence.type=jdbc -Dquarkus.datasource.db-kind=postgresql -Dkogito.persistence.proto.marshaller=false" -# Expose to RUN so build-app.sh can use them (--build-arg-file from argfile.conf overrides ARG above) -ENV QUARKUS_EXTENSIONS=${QUARKUS_EXTENSIONS} -ENV MAVEN_ARGS_APPEND=${MAVEN_ARGS_APPEND} - # Argument for passing the resources folder if not current context dir ARG WF_RESOURCES @@ -45,8 +41,8 @@ COPY --chown=1001 ${WF_RESOURCES} ./resources/ RUN ls -la ./resources ENV swf_home_dir=/home/kogito/serverless-workflow-project -# Do not cp resources/src to ./src to avoid duplicate workflow id (Kogito scans both and fails with "Duplicated item found with id") -# build-app.sh ./resources builds from ./resources only. +RUN if [[ -d "./resources/src" ]]; then cp -r ./resources/src/* ./src/; fi + RUN /home/kogito/launch/build-app.sh ./resources #============================= diff --git a/scripts/gen_manifests.sh b/scripts/gen_manifests.sh index bc0ee61a..a356e464 100755 --- a/scripts/gen_manifests.sh +++ b/scripts/gen_manifests.sh @@ -18,10 +18,7 @@ command -v kubectl cd "${WORKFLOW_FOLDER}" -# Append to application.properties when present (WORKFLOW_FOLDER is already the dir with .sw.yaml, possibly a subdir) -if [ -f application.properties ]; then - echo -e "\nkie.flyway.enabled=true" >> application.properties -fi +echo -e "\nkie.flyway.enabled=true" >> application.properties kn-workflow gen-manifest --profile='gitops' \ --image="${WORKFLOW_IMAGE_REGISTRY}/${WORKFLOW_IMAGE_NAMESPACE}/${WORKFLOW_IMAGE_REPO}:${WORKFLOW_IMAGE_TAG}" \ diff --git a/workflows/bulk-import-git-repos/README.md b/workflows/bulk-import-git-repos/README.md index 2032f642..85aec38c 100644 --- a/workflows/bulk-import-git-repos/README.md +++ b/workflows/bulk-import-git-repos/README.md @@ -38,7 +38,7 @@ mvn clean install Generate manifests, from the root of the repository: ``` -make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests \ +make WORKFLOW_ID=bulk-import-git-repos WORKFLOW_SUBDIR=bulk-import-git-repos/src/main/resources gen-manifests cp -rf /tmp/serverless-workflows/workflows/bulk-import-git-repos/src/main/resources/manifests ./workflows/bulk-import-git-repos ``` diff --git a/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml b/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml index 70d77a53..711f5dfe 100755 --- a/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml +++ b/workflows/experimentals/github-pr/manifests/04-sonataflow_gh-pr.yaml @@ -212,14 +212,14 @@ spec: persistence: postgresql: secretRef: - name: backstage-psql-secret - userKey: POSTGRES_USER - passwordKey: POSTGRES_PASSWORD + name: sonataflow-psql-postgresql + userKey: postgres-username + passwordKey: postgres-password serviceRef: - name: backstage-psql + name: sonataflow-psql-postgresql port: 5432 - databaseName: postgres - databaseSchema: public + databaseName: sonataflow + databaseSchema: gh-pr status: address: {} lastTimeRecoverAttempt: null diff --git a/workflows/experimentals/github-pr/src/main/resources/application.properties b/workflows/experimentals/github-pr/src/main/resources/application.properties index 43f3840f..6b051f92 100644 --- a/workflows/experimentals/github-pr/src/main/resources/application.properties +++ b/workflows/experimentals/github-pr/src/main/resources/application.properties @@ -9,9 +9,8 @@ quarkus.log.level=INFO quarkus.rest-client.scafolderMock_yaml.url=http://127.0.0.1:8282 quarkus.rest-client.github_yaml.url=https://api.github.com - #ghToken= -# quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} +#quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} quarkus.kogito.devservices.enabled=false quarkus.openapi-generator.github_yaml.auth.BearerToken.token-propagation=true quarkus.openapi-generator.github_yaml.auth.BearerToken.header-name=X-Authorization-Github \ No newline at end of file From 163c5f659454413909a45abab21a288d7333e2df Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 16:34:15 +0200 Subject: [PATCH 12/14] fix image build failing Signed-off-by: Oleksandr Andriienko --- pipeline/workflow-builder.Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/pipeline/workflow-builder.Dockerfile b/pipeline/workflow-builder.Dockerfile index 818e7b8e..d5d699ab 100644 --- a/pipeline/workflow-builder.Dockerfile +++ b/pipeline/workflow-builder.Dockerfile @@ -41,7 +41,6 @@ COPY --chown=1001 ${WF_RESOURCES} ./resources/ RUN ls -la ./resources ENV swf_home_dir=/home/kogito/serverless-workflow-project -RUN if [[ -d "./resources/src" ]]; then cp -r ./resources/src/* ./src/; fi RUN /home/kogito/launch/build-app.sh ./resources From abb1061b25a3166b003603c5c2c9fc987015545f Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 17:01:59 +0200 Subject: [PATCH 13/14] cleanup Signed-off-by: Oleksandr Andriienko --- workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm | 1 - .../github-pr/manifests/00-secret_gh-pr-secrets.yaml | 3 +-- .../github-pr/src/main/resources/application.properties | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm b/workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm index 78705d71..f8b24c20 100644 --- a/workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm +++ b/workflows/bulk-import-git-repos/src/main/docker/Dockerfile.jvm @@ -1,7 +1,6 @@ ARG BUILDER_IMAGE ARG RUNTIME_IMAGE -# registry.redhat.io/openshift-serverless-1/logic-swf-devmode-rhel8:1.36.0 FROM ${BUILDER_IMAGE:-registry.redhat.io/openshift-serverless-1/logic-swf-builder-rhel8:1.35.0-6} AS builder ARG QUARKUS_EXTENSIONS diff --git a/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml b/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml index e397fa92..5b5c8deb 100644 --- a/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml +++ b/workflows/experimentals/github-pr/manifests/00-secret_gh-pr-secrets.yaml @@ -1,8 +1,7 @@ apiVersion: v1 data: - ghToken: Z2hwX0FCQzEyMw== + NOTIFICATIONS_BEARER_TOKEN: "" kind: Secret -type: Opaque metadata: creationTimestamp: null name: gh-pr-secrets diff --git a/workflows/experimentals/github-pr/src/main/resources/application.properties b/workflows/experimentals/github-pr/src/main/resources/application.properties index 6b051f92..5b86e7e3 100644 --- a/workflows/experimentals/github-pr/src/main/resources/application.properties +++ b/workflows/experimentals/github-pr/src/main/resources/application.properties @@ -8,7 +8,6 @@ quarkus.log.category."org.apache.http".level=DEBUG quarkus.log.level=INFO quarkus.rest-client.scafolderMock_yaml.url=http://127.0.0.1:8282 quarkus.rest-client.github_yaml.url=https://api.github.com - #ghToken= #quarkus.openapi-generator.github_yaml.auth.BearerToken.bearer-token=${ghToken} quarkus.kogito.devservices.enabled=false From 76d1b458ccccbb0af4b9da24720b852295347911 Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Wed, 18 Mar 2026 17:07:22 +0200 Subject: [PATCH 14/14] revert test changes Signed-off-by: Oleksandr Andriienko --- .github/workflows/main.yml | 58 +++++++++++++++++++------------------- Makefile | 3 +- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 213a120c..6aa0b79c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ on: default: false secrets: HELM_REPO_TOKEN: - required: false + required: true permissions: contents: write @@ -26,8 +26,8 @@ permissions: env: WF_DEPLOY_REPO: rhdhorchestrator/serverless-workflows - REGISTRY_REPO: aandriienko - # GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} + REGISTRY_REPO: orchestrator + GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} jobs: build: @@ -121,30 +121,30 @@ jobs: }) ).data[0]; - # - name: Send PRs to deploy repo - # if: ${{ ! inputs.it_mode }} - # env: - # GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} - # run: | - # gh auth status - - # WORKDIR=${{ runner.temp }}/serverless-workflows - - # # determine pr or commit url - # if [ ${{ fromJSON(steps.get_pr_data.outputs.result)}} != "" ]; then - # PR_OR_COMMIT_URL="${{ fromJSON(steps.get_pr_data.outputs.result).html_url }}" - # else - # PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" - # fi - - # sh scripts/create_or_update_automated_pr.sh $WF_DEPLOY_REPO \ - # ${{ inputs.workflow_id }} \ - # ${PR_OR_COMMIT_URL} \ - # "" \ - # scripts/create_automated_pr.sh \ - # 'rhdhorchestrator@redhat.com' \ - # 'orchestrator-ci' \ - # $WORKDIR \ - # ${{ env.GH_TOKEN }} \ - # ${{ github.sha }} + - name: Send PRs to deploy repo + if: ${{ ! inputs.it_mode }} + env: + GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} + run: | + gh auth status + + WORKDIR=${{ runner.temp }}/serverless-workflows + + # determine pr or commit url + if [ ${{ fromJSON(steps.get_pr_data.outputs.result)}} != "" ]; then + PR_OR_COMMIT_URL="${{ fromJSON(steps.get_pr_data.outputs.result).html_url }}" + else + PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + fi + + sh scripts/create_or_update_automated_pr.sh $WF_DEPLOY_REPO \ + ${{ inputs.workflow_id }} \ + ${PR_OR_COMMIT_URL} \ + "" \ + scripts/create_automated_pr.sh \ + 'rhdhorchestrator@redhat.com' \ + 'orchestrator-ci' \ + $WORKDIR \ + ${{ env.GH_TOKEN }} \ + ${{ github.sha }} diff --git a/Makefile b/Makefile index b52b7de7..b7893440 100644 --- a/Makefile +++ b/Makefile @@ -74,8 +74,7 @@ MVN_OPTS ?= -B IMAGE_NAME := "" REGISTRY ?= quay.io -REGISTRY_REPO ?= "aandriienko" -#$(shell id -un) +REGISTRY_REPO ?= $(shell id -un) REGISTRY_USERNAME ?= "" REGISTRY_PASSWORD ?= "" IMAGE_PREFIX ?= serverless-workflow