From 9f3b1d703805330a3022d2c9ba3b530916d60f20 Mon Sep 17 00:00:00 2001 From: Jakob Kjaer Date: Thu, 16 Nov 2023 10:19:15 +1000 Subject: [PATCH] handle fork pr's --- .github/workflows/template.yml | 4 +++- .vscode/settings.json | 6 ++++++ src/HowToUse.md | 19 +++++++++++++++++++ src/create_template.js | 7 ++++--- test/PR.txt | 10 +++++++--- 5 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml index 5fefebb..c6f0879 100644 --- a/.github/workflows/template.yml +++ b/.github/workflows/template.yml @@ -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: diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d783ec4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.watcherExclude": { + "**/node_modules/*/**": false, + "**/node_modules/[!@]*/**/*": true + } +} \ No newline at end of file diff --git a/src/HowToUse.md b/src/HowToUse.md index f1e6c9f..f766fca 100644 --- a/src/HowToUse.md +++ b/src/HowToUse.md @@ -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] +``` \ No newline at end of file diff --git a/src/create_template.js b/src/create_template.js index 1a95ecb..26efca2 100644 --- a/src/create_template.js +++ b/src/create_template.js @@ -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) @@ -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)`) diff --git a/test/PR.txt b/test/PR.txt index 1170dba..778cad3 100644 --- a/test/PR.txt +++ b/test/PR.txt @@ -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]