-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (42 loc) · 1.8 KB
/
Copy pathgh-to-tw-link.yml
File metadata and controls
49 lines (42 loc) · 1.8 KB
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
name: Github to Teamwork link
on:
workflow_dispatch:
pull_request:
types: [opened]
env:
GH_TO_TW_API_KEY: ${{ secrets.GH_TO_TW_API_KEY }}
GH_TO_TW_API_PWD: ${{ secrets.GH_TO_TW_API_PWD }}
GH_TO_TW_SECRET: ${{ secrets.GH_TO_TW_SECRET }}
jobs:
parse-description:
runs-on: ubuntu-latest
steps:
- name: Extract info and call API
uses: actions/github-script@v7
with:
script: |
const description = context.payload.pull_request.body || "";
const urlMatch = description.match(/##\s*Issue\s*\n(https?:\/\/\S+)/i);
if (urlMatch) {
const teamworkUrl = urlMatch[1];
const body = JSON.stringify({
"taskUrl": teamworkUrl,
"githubUrl": context.payload.pull_request.html_url
});
const headers = {
"Content-Type": "application/json",
"x-gh2tw-auth": process.env.GH_TO_TW_SECRET,
};
const response = await fetch(
"https://gh-to-tw-links.indigotree.workers.dev",
{
method: "POST",
headers,
body,
}
);
const result = await response.json();
console.log("API response:", result);
} else {
console.log("No issue URL found in PR description.");
}