Skip to content

Commit dd7af37

Browse files
authored
Ai agent automated maintenance (#18)
* refactor: remove redundant JSON decoding in Shopee OpenAPI announcement script * add: automate GitHub issue creation for Shopee OpenAPI announcements * update: replace GITHUB_TOKEN with PERSONAL_ACCESS_TOKEN in workflow for triggering next workflow * update: refine Shopee OpenAPI announcement instructions to focus solely on major API changes * update: configure Junie workflow with model and server settings, adjust Shopee announcement script path
1 parent f717184 commit dd7af37

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

bin/shopee-openapi-announcement renamed to .github/scripts/shopee-openapi-announcement

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const SHOPEE_API_URL = 'https://open.shopee.com/opservice/api/v1';
66

77
// get shopee openapi updates list
88
$shopee_openapi_updates = curl_get(SHOPEE_API_URL.'/content/list?SPC_CDS_VER=2&category_id=55&page_size=10&page_index=1');
9-
$shopee_openapi_updates = json_decode($shopee_openapi_updates, true);
109

1110
// latest announcement
1211
$latest_announcement = $shopee_openapi_updates['data'][0] ?? null;
@@ -34,7 +33,6 @@ if (isset($searchResult['total_count']) && $searchResult['total_count'] > 0) {
3433

3534
// get announcement content
3635
$latest_announcement_data = curl_get(SHOPEE_API_URL.'/content/detail?SPC_CDS_VER=2&id='.$latest_announcement['id']);
37-
$latest_announcement_data = json_decode($latest_announcement_data, true);
3836

3937
// announcement content
4038
$blocks = json_decode($latest_announcement_data['detail'], true);
@@ -48,10 +46,29 @@ $issue_body = <<<MARKDOWN
4846
{$markdownOutput}
4947
5048
---
51-
@junie-agent Please check the changes for this endpoint in Shopee's Openapi Announcement, update the corresponding PHP source code in the repo, and create a new Pull Request for review.
49+
@junie-agent Please review the API changes described above. Focus **ONLY** on major updates such as adding new endpoints or removing/taking legacy APIs offline. You can safely ignore any other changes regarding request/response parameters or fields. Update the PHP code and create a new PR for review.
5250
MARKDOWN;
5351

54-
echo $markdownOutput;exit;
52+
// temporary save issue body to file
53+
file_put_contents(__DIR__ . '/issue_body.md', $issue_body);
54+
55+
// run gh issue create command, add label "shopee-announcement" to filter issues
56+
$command = sprintf(
57+
'gh issue create --repo %s --title %s --body-file %s --label "shopee-announcement"',
58+
escapeshellarg($repo),
59+
escapeshellarg($issue_title),
60+
escapeshellarg(__DIR__ . '/issue_body.md')
61+
);
62+
63+
exec($command, $output, $returnVar);
64+
if ($returnVar !== 0) {
65+
echo "Failed to create issue: " . implode("\n", $output) . "\n";
66+
exit(1);
67+
}
68+
69+
unlink(__DIR__ . '/issue_body.md');
70+
echo "Issue created successfully.\n";
71+
echo $markdownOutput;
5572

5673
function curl_get($url, $github_token = null)
5774
{

.github/workflows/junie.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ jobs:
3333
uses: JetBrains/junie-github-action@v0
3434
with:
3535
junie_api_key: ${{ secrets.JUNIE_API_KEY }}
36+
allowed_mcp_servers: "shopee,mcp_github_checks_server,mcp_github_inline_comment_server"
37+
model: "gpt-codex"

.github/workflows/shopee-announcements.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ jobs:
3131
# Check duplicates via API and create an issue using GitHub CLI (gh)
3232
- name: Process Shopee Announcement and Create GitHub Issue
3333
env:
34-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required variable for automatic authentication in gh CLI and GitHub API
34+
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # use PERSONAL_ACCESS_TOKEN for automated triggering next workflow
3535
REPOSITORY_NAME: ${{ github.repository }}
36-
run: php bin/shopee-openapi-announcement
36+
run: php .github/scripts/shopee-openapi-announcement

0 commit comments

Comments
 (0)