-
Notifications
You must be signed in to change notification settings - Fork 28
Bulk import workflow sample #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b03b3f8
7c4449b
ded6580
d393445
3031cda
c500460
f667b91
8a6cc13
6953cb8
68ece98
e313e4b
163c5f6
abb1061
76d1b45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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: bulk-import-git-repos | ||
| secrets: inherit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
|
Comment on lines
43
to
44
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this line removed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RUN if [[ -d "./resources/src" ]]; then cp -r ./resources/src/* ./src/; fiThis command copies files from to the After that we have workflow file inside container. Next Dockerfile command: RUN /home/kogito/launch/build-app.sh ./resourcesFragment of this script: ...
destination="${KOGITO_HOME}/serverless-workflow-project/src/main/resources/"
log_info "-> Destination folder is ${destination}"
cp -vR ${resources_path}/* ${destination}
...
And build image log for this command INFO -> Destination folder is /home/kogito/serverless-workflow-project/src/main/resources/
'/home/kogito/serverless-workflow-project/resources/src/main/resources' -> '/home/kogito/serverless-workflow-project/src/main/resources/src/main/resources'
'/home/kogito/serverless-workflow-project/resources/src/main/resources/application.properties' -> '/home/kogito/serverless-workflow-project/src/main/resources/src/main/resources/application.properties'
'/home/kogito/serverless-workflow-project/resources/src/main/resources/create-pr-universal.sw.yaml' -> '/home/kogito/serverless-workflow-project/src/main/resources/src/main/resources/create-pr-universal.sw.yaml'So build-app.sh provides duplicated workflow file. These workflows has a bit different path: Then build-app.sh makes maven build and fails with "Duplicated item found with id universal-pr":
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch! |
||
| RUN /home/kogito/launch/build-app.sh ./resources | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # 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=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: | ||
|
|
||
| ``` | ||
| make WORKFLOW_ID=bulk-import-git-repos build-image | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
|
|
||
| kie.flyway.enabled=true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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. | ||
| # 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!