forked from microsoft/botbuilder-js
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate-outdated-packages-issue.yml
More file actions
106 lines (94 loc) · 3.73 KB
/
create-outdated-packages-issue.yml
File metadata and controls
106 lines (94 loc) · 3.73 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Outdated Packages
on:
workflow_dispatch:
push:
branches:
- main
- 'joelmut/test/package-notification'
# schedule:
# # Daily at 8:20 UTC
# - cron: '20 8 * * *'
# TODO: for testing use a manual execution.
jobs:
issue:
runs-on: windows-latest
permissions:
issues: write
env:
REPORT_ID: "id:outdated-packages"
WORKING_DIR: "botframework-sdk"
steps:
- name: use node 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: check existing issue
run: |
$json = Invoke-Expression "gh issue list --search `"in:body *${{ env.REPORT_ID }}*`" --repo $GITHUB_REPOSITORY --app github-actions --state open --json id,number,body" | ConvertFrom-Json
if($json.body -eq $null) {
echo "ISSUE_NUMBER=$($json.number)" >> "$GITHUB_OUTPUT"
exit 0
}
$start = $json.body.IndexOf("<!--");
$end = $json.body.IndexOf("-->") + 3;
$header = $json.body.Substring($start, $end - $start)
$hash = $header.Split("hash:")[1].Split("`n")[0].Trim();
echo "ISSUE_HASH=$hash" >> "$GITHUB_OUTPUT"
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
# - name: get script from botframework-sdk
# run: |
# wget <botframework-sdk repo>
# working-directory: ${{ WORKING_DIR }}
- name: generate report
run: |
$json = node --experimental-transform-types ./botframework-sdk/report.ts | ConvertFrom-Json
if($json.integrity -eq $env:ISSUE_HASH) {
echo "No changes detected. Exiting..."
exit 0
}
"<!--
${REPORT_ID}
hash:$($json.integrity)
-->
$($json.markdown)" | Out-File ./botframework-sdk/report.md
Get-Content ./botframework-sdk/report.md
shell: powershell
env:
ISSUE_HASH: ${{ steps.check-existing-issue.outputs.ISSUE_HASH }}
- name: create/update issue
if: ${{ steps.check-existing-issue.outputs.ISSUE_HASH != '' }}
run: |
$content = Get-Content ./botframework-sdk/report.md;
if($env:ISSUE_NUMBER -eq '') {
gh issue create --title "Outdated packages" --body $content --repo $GITHUB_REPOSITORY;
} else {
gh issue edit $env:ISSUE_NUMBER --body $content --repo $GITHUB_REPOSITORY;
}
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
ISSUE: ${{ github.event.issue.html_url }}
ISSUE_NUMBER: ${{ steps.check-existing-issue.outputs.ISSUE_NUMBER }}
ISSUE_HASH: ${{ steps.check-existing-issue.outputs.ISSUE_HASH }}
# https://cli.github.com/manual/gh_issue_create
# - run: |
# gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY
# env:
# GH_TOKEN: ${{ github.token }}
# ISSUE: ${{ github.event.issue.html_url }}
# Get outdated packages
# Generate hash
# Check if existing issue is open by checking the cache || title || body.hash, and save a boolean flag
# If the issue exists, compare hash with the "Get outdated packages" step
# If the hash is the same, exit
# Generate .md report
# if boolean flag is true, update the issue with the new report
# if boolean flag is false, create a new issue with the report
# - run: |
# https://cli.github.com/manual/gh_issue_create
# gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY
# env:
# GH_TOKEN: ${{ github.token }}
# ISSUE: ${{ github.event.issue.html_url }}