-
Notifications
You must be signed in to change notification settings - Fork 124
fix(ci): resolve JSON double-encoding in sync metadata workflow #989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ci): resolve JSON double-encoding in sync metadata workflow #989
Conversation
|
@sheikhlimon is attempting to deploy a commit to the recode Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs. In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to LinkedIn. Your contributions are highly appreciated!😊 Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging @sanjay-kv. We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰 🎁 check our list of amazing people we sponsored so far: GitHub Sponsorship. ✨ 📚Your perks for contribution to this community 👇🏻
If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊 |
Synced data from Linked IssuesLabels:
Assignees:
Milestones:
|
|
Ready for review @iitzIrFan |
8dda805 to
7aefb94
Compare
87ac17c to
80ed039
Compare
d16ab6d to
d639a87
Compare
- Replaced `setLabels()` with `addLabels()` to prevent race conditions where concurrent label additions could be lost. - Labels from linked issues are now added without removing existing PR labels. - Milestones from linked issues continue to be synced. - Adds a comment to the PR summarizing synchronized metadata.
|
@iitzIrFan i think my last commit change should work right.... vercel agent review came to the rescue @sanjay-kv did you turn it on.. or it was working from the beginning... @iitzIrFan its shows error now because its still checking the previous gitflow i have attached the log below thats coming from merged gitflow... Run actions/github-script@v7
with:
github-token: ***
script: const data = JSON.parse('"{\"issues\":[\"986\"],\"pr\":989}"');
const prNumber = data.pr;
const issueNumbers = data.issues || [];
if (issueNumbers.length === 0) {
console.log("No linked issues found");
return;
}
for (const issueNumber of issueNumbers) {
try {
// Fetch issue
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber)
});
console.log(`Syncing metadata from Issue #${issueNumber} to PR #${prNumber}`);
// --- Sync Labels ---
const issueLabels = issue.labels.map(l => l.name);
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
const currentPRLabels = pr.labels.map(l => l.name);
const combinedLabels = Array.from(new Set([...currentPRLabels, ...issueLabels]));
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: combinedLabels
});
console.log(`Labels applied: ${combinedLabels.join(', ')}`);
// --- Sync Milestone ---
if (issue.milestone) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
milestone: issue.milestone.number
});
console.log(`Milestone synced: ${issue.milestone.title}`);
}
// --- Sync Projects (GitHub Projects v2) ---
if(issue.project_cards_url) {
// Fetch project cards of issue
const cardsResponse = await github.rest.projects.listCards({
column_id: issue.project_cards_url.split('/').pop() // last part is column_id
}).catch(()=>({data:[]}));
for(const card of cardsResponse.data || []) {
await github.rest.projects.createCard({
column_id: card.column_id,
content_id: prNumber,
content_type: 'PullRequest'
});
console.log(`Added PR #${prNumber} to project card in column ${card.column_id}`);
}
}
// --- Optionally: Add a comment on PR ---
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `✅ Synchronized metadata from Issue #${issueNumber}:\nLabels: ${issueLabels.join(', ')}\nMilestone: ${issue.milestone ? issue.milestone.title : 'None'}`
});
} catch (error) {
console.error(`Error syncing issue #${issueNumber} to PR #${prNumber}:`, error.message);
} |
|
I turned vercel agent on got $100 offer so opted for it |
- Stop direct interpolation of workflow outputs into github-script to avoid malformed JSON errors. - Pass issues and PR number via environment variables and parse from process.env. - Add defensive JSON parsing with cleaning for extra quotes/newlines. - Fix typo in PR comment: use issue.milestone correctly. - Use addLabels() instead of setLabels() to prevent race conditions and preserve existing PR labels. - Sync milestones and add a comment summarizing the synchronized metadata.
|
@sheikhlimon this got few conflicts, can you help |
Yeah you merged the test PR as well should have closed that |
Description
Fixes #986
Type of Change
Changes Made
returntocore.setOutput()to prevent double-encodingissuesandpr) for cleaner parsingTesting
Test Output