Skip to content

Commit

Permalink
Merge pull request #26 from TIBCOSoftware/import-flow-example
Browse files Browse the repository at this point in the history
Added import flow example for BWCE and FLOGO in tibco-examples folder.
  • Loading branch information
hpeters83 authored Aug 27, 2024
2 parents edf1a36 + e64b66e commit d95ff6f
Show file tree
Hide file tree
Showing 5 changed files with 351 additions and 42 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "1.2.0",
"version": "1.2.2",
"private": true,
"engines": {
"node": "18 || 20"
Expand Down
20 changes: 20 additions & 0 deletions tibco-examples/import-flow/catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: backstage.io/v1alpha1
kind: Group
metadata:
name: tibco-imported
description: Tibco importer group
spec:
type: organization
profile:
displayName: Tibco imported
email: [email protected]
children: []
---
apiVersion: backstage.io/v1alpha1
kind: Location
metadata:
name: import-flow-locations
spec:
targets:
- ./import-flow-bwce.yaml
- ./import-flow-flogo.yaml
167 changes: 167 additions & 0 deletions tibco-examples/import-flow/import-flow-bwce.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: import-flow-bwce
title: Import flow for BWCE projects
description: Import existing BWCE projects into TIBCO Developer Hub
tags:
- import-flow
- tibco
- template
- developer-hub
spec:
owner: group:default/tibco-imported
type: import-flow

parameters:
- title: Repository Location
required:
- repoUrl
properties:
repoUrl:
title: GitHub repository with Existing BWCE Project
type: string
ui:field: RepoUrlPicker
ui:options:
allowedHosts:
- github.com

- title: Fill in some steps
required:
- application
- owner
properties:
application:
title: BWCE Application
type: string
description: Name of the BWCE Application to import
owner:
title: Owner
type: string
description: Owner of the template
ui:field: OwnerPicker
ui:options:
allowedKinds:
- Group

# The import flow consist out of 4 steps:
# 1. Fetch the project from GitHub
# 2. Generate the Component YAML
# 3. Commit the Component YAML file back to the GitHub project branch creating a pull request
# 4. Register the Component in the catalog

steps:
- id: fetch
name: Fetch project
action: fetch:plain
input:
url: ${{ "https://" + (parameters.repoUrl | parseRepoUrl).host + "/" + (parameters.repoUrl | parseRepoUrl).owner + "/" + (parameters.repoUrl | parseRepoUrl).repo }}

- id: extract
name: Extract Parameters
action: tibco:extract-parameters
input:
failOnError: true
extractParameters:
bwce_project_name:
type: xml
filePath: ${{ parameters.application + "/" + parameters.application + ".application/.project" }}
# For xml type extractParameters both json path and xpath are supported
# jsonPath: $.projectDescription.name
xPath: string(/projectDescription/name)
bwce_project_description:
type: xml
filePath: ${{ parameters.application + "/" + parameters.application + ".application/.project" }}
# For xml type extractParameters both json path and xpath are supported
# jsonPath: $.projectDescription.comment
xPath: string(/projectDescription/comment)

# extractParameters type json, file and workspace also supported
# example_parameter1:
# type: json
# filePath: <File path>
# jsonPath: <Json path>
# example_parameter2:
# type: file
# filePath: <File path>
# regex: <Regex>
# example_parameter3:
# type: workspace
# onlyName: true
# directoryPath: <Directory path>
# regex: <Regex>

- id: crateYaml
name: Create YAML
action: tibco:create-yaml
input:
# Add application name
outputFile: ${{ parameters.application + '/'+ parameters.application + "-bwce-catalog-info.yaml" }}
# outputFile: "bwce-catalog-info.yaml"
outputStructure:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
# Output of the Extract Parameters action step will always be an array, so we are using first item from the array
name: ${{ steps.extract.output.bwce_project_name[0]}}
description: ${{ steps.extract.output.bwce_project_description[0] }}
tags:
- bwce
links:
- title: TIBCO Business Works
url: https://www.tibco.com/products/tibco-businessworks
annotations:
github.com/project-slug: ${{ "https://" + (parameters.repoUrl | parseRepoUrl).host + "/" + (parameters.repoUrl | parseRepoUrl).owner + "/" + (parameters.repoUrl | parseRepoUrl).repo }}
backstage.io/techdocs-ref: dir:.
spec:
type: bwce
lifecycle: production
owner: ${{ parameters.owner }}

# The import flow debug step, enable it for debugging

# - id: Log Debug
# name: Debug Log
# action: debug:log
# input:
# message: "Fetched the BWCE Skeleton template"
# listWorkspace: true
# bwce_project_name: ${{ steps.extract.output.bwce_project_name[0] }}
# bwce_project_description: ${{ steps.extract.output.bwce_project_description[0] }}
# repoUrl: ${{ parameters.repoUrl }}

- id: cpr
name: Create Pull Request in Current Repo
action: publish:github:pull-request
input:
repoUrl: ${{ parameters.repoUrl }}
update: true
branchName: ${{ parameters.application.replace("/", ".") }}
title: ${{ parameters.application }}
description: This PR adds a Component YAML to this Repository.

# Optionally you can leave this step out, if your developer hub synchronize with the GitHub organization
# When the pull request is merged, the component will be registered by the GitHub catalog provider, below is the example configuration
# catalog:
# providers:
# github:
# providerId:
# organization: '<organization>'
# catalogPath: '**/*catalog-info.yaml'
# schedule:
# frequency: { minutes: 30 }

- id: register
name: Register
action: catalog:register
input:
catalogInfoUrl: ${{ "https://" + (parameters.repoUrl | parseRepoUrl).host + "/" + (parameters.repoUrl | parseRepoUrl).owner + "/" + (parameters.repoUrl | parseRepoUrl).repo + "/blob/" + parameters.application.replace("/", ".") + "/" + parameters.application + "/" + parameters.application +"-bwce-catalog-info.yaml" }}

output:
links:
# If you are not using register step above, remove the below Open in catalog link.
- title: Open in catalog
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}
- title: Repository (Pull Request)
url: ${{ steps.cpr.output.remoteUrl }}
Loading

0 comments on commit d95ff6f

Please sign in to comment.