Skip to content

Commit

Permalink
handle fork pr's
Browse files Browse the repository at this point in the history
  • Loading branch information
uxkjaer committed Nov 16, 2023
1 parent 5e9cf59 commit 9f3b1d7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
- uses: actions/checkout@v4
name: "Checkout repository"
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: "Setup Node.js"
uses: actions/setup-node@v3
with:
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.watcherExclude": {
"**/node_modules/*/**": false,
"**/node_modules/[!@]*/**/*": true
}
}
19 changes: 19 additions & 0 deletions src/HowToUse.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,22 @@ Each template will have a short description and an image that shows the template
# Contribute

If you have a template that you would like to share with the community. You will need to download your architecture diagram in XML format from diagrams.net or draw.io. Open the Github editor via this [link](https://github.dev/rsletta/sap_btp_icons_drawio_lib) or fork the [repository](https://github.com/rsletta/sap_btp_icons_drawio_lib) and add your xml file into upload directory and create a pull request and fill out the details requested. These details are used to create the page that shows the template.

If the pull request doesn't add the template automatically, then please use the following template

```
# Title
[Title]
# Description
[Description]
# Image
[Paste a copy of your image]
# Tags
[Add any relevant tags]
```
7 changes: 4 additions & 3 deletions src/create_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {parse, toMd} from 'md-2-json'
}
*/
async function main() {
const body = process.env.Body
// const body = await readFile('./test/PR.txt', 'utf-8')
// const body = process.env.Body
const body = await readFile('./test/PR.txt', 'utf-8')

const jsonBody = parse(body)
// console.log(jsonBody)
Expand All @@ -24,11 +24,12 @@ if (files.length !== 2 || (!regex.test(files[0].name) && !regex.test(files[1].na
} else {
try {
const filename = files.find((file) => file.name.includes("xml"))?.name
const targetFileName = filename.replace(/\s/g, "")
const path = './src/templates/' +templateName
const mdFilePath = `./src/templates/${templateName}/${templateName}.md`

await mkdir(path)
await cp('./upload/' +filename, path +"/" +filename)
await cp('./upload/' +filename, path +"/" +targetFileName)
await writeFile(mdFilePath,body)
await appendFile(mdFilePath, `\n\n
[Open Diagram](https://app.diagrams.net/?create=https://raw.githubusercontent.com/${process.env.Repo}/main/src/templates/${templateName}/${filename}&clibs=Uhttps://raw.githubusercontent.com/mauriciolauffer/sap_btp_icons_drawio_lib/main/libs/SAP_BTP_Service_Icons_latest.xml)`)
Expand Down
10 changes: 7 additions & 3 deletions test/PR.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Title

Princip
[Title]

# Description

Test2131231
[Description]

# Image
![image](https://github.com/rsletta/sap_btp_icons_drawio_lib/assets/8186370/1ae069e5-5528-4576-98e2-d4efa7884bbf)
[Paste a copy of your image]

# Tags

[Add any relevant tags]

0 comments on commit 9f3b1d7

Please sign in to comment.