forked from RoadieHQ/sample-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappend-replace-action.yaml
87 lines (86 loc) · 2.91 KB
/
append-replace-action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: modify-readme
title: Modify README
description: Appends text and replaces a placeholder in README.md
spec:
owner: roadie
type: service
parameters:
- title: PR Data
properties:
repository:
title: Repository name
type: string
description: The name of the repository
org:
title: Repository Organisation
type: string
description: The Github org that the repository is in
pr_branch:
title: PR Branch
type: string
description: The new branch to make a pr from
- title: Append content
properties:
path:
title: Path
type: string
description: The path to the file you want to append this content to in the scaffolder workspace
name:
title: Name
type: string
description: The some name
owner:
title: Owner
type: string
description: Owner of the component
ui:field: OwnerPicker
ui:options:
catalogFilter:
kind: Group
replacePattern:
type: string
description: "Pattern to replace in the README file"
default: "PLACEHOLDER"
replaceWith:
type: string
description: "Replacement text for the pattern"
default: "Actual content"
steps:
- id: fetch-repo
name: Fetch repo
action: fetch:plain
input:
url: https://github.com/${{ parameters.org }}/${{ parameters.repository }}
- id: append-file
name: Append To File Or Create New
action: roadiehq:utils:fs:append
input:
path: ${{ parameters.path }}
content: "test name: ${{ parameters.name }}\n
test owner1: ${{ parameters.owner | replace(\"group:roadiehq/\", \"\") }}\n
test owner2: ${{ parameters.owner | replace(\"group:.*/\", \"\") }}\n
test owner3: ${{ parameters.owner | replace(\"group\", \"poop\") }}\n"
- id: replace-text
name: Replace Placeholder in README
action: roadiehq:utils:fs:replace
input:
files:
- file: ${{ parameters.path }}
find: "${{ parameters.replacePattern }}"
replaceWith: "${{ parameters.replaceWith }}"
- id: publish-pr
name: Publish PR
action: publish:github:pull-request
input:
repoUrl: github.com?repo=${{ parameters.repository }}&owner=${{ parameters.org }}
branchName: ${{ parameters.pr_branch }}
title: "Add test content to ${{ parameters.owner | replace(\"group:.*/\", \"\") }}"
description: Test append or create file
- id: log-message
name: Log PR URL
action: debug:log
input:
message: "RemoteURL: ${{ steps[\"publish-pr\"].output.remoteUrl }} owner - ${{ parameters.owner | replace(\"group:.*/\", \"\") }}"