Skip to content

Commit 8c740d4

Browse files
Merge branch 'main' into fix-interviewprep-badge
2 parents 2511c8e + 700cf93 commit 8c740d4

76 files changed

Lines changed: 29246 additions & 1688 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
node_modules
2+
npm-debug.log
3+
Dockerfile
4+
docker-compose.yml
5+
.dockerignore
26
.git
7+
.gitignore
8+
logs
39
.DS_Store
410
build
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Sync Issue Metadata to PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize, reopened]
6+
7+
permissions:
8+
pull-requests: write
9+
issues: write
10+
contents: read
11+
repository-projects: write
12+
13+
jobs:
14+
sync-pr-metadata:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Extract linked issue(s) from PR
22+
id: extract-issues
23+
uses: actions/github-script@v7
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
script: |
27+
const prNumber = context.payload.pull_request.number;
28+
const prTitle = context.payload.pull_request.title || '';
29+
const prBody = context.payload.pull_request.body || '';
30+
31+
// Regex patterns for issue references
32+
const patterns = [
33+
/(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi,
34+
/#(\d+)/g
35+
];
36+
37+
const issueNumbers = new Set();
38+
const text = prTitle + ' ' + prBody;
39+
40+
for (const pattern of patterns) {
41+
for (const match of text.matchAll(pattern)) {
42+
issueNumbers.add(match[1]);
43+
}
44+
}
45+
46+
return JSON.stringify({ issues: Array.from(issueNumbers), pr: prNumber });
47+
48+
- name: Sync Issue Metadata to PR
49+
uses: actions/github-script@v7
50+
with:
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
script: |
53+
const data = JSON.parse('${{ steps.extract-issues.outputs.result }}');
54+
const prNumber = data.pr;
55+
const issueNumbers = data.issues || [];
56+
57+
if (issueNumbers.length === 0) {
58+
console.log("No linked issues found");
59+
return;
60+
}
61+
62+
for (const issueNumber of issueNumbers) {
63+
try {
64+
// Fetch issue
65+
const { data: issue } = await github.rest.issues.get({
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
issue_number: parseInt(issueNumber)
69+
});
70+
71+
console.log(`Syncing metadata from Issue #${issueNumber} to PR #${prNumber}`);
72+
73+
// --- Sync Labels ---
74+
const issueLabels = issue.labels.map(l => l.name);
75+
const { data: pr } = await github.rest.pulls.get({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
pull_number: prNumber
79+
});
80+
const currentPRLabels = pr.labels.map(l => l.name);
81+
const combinedLabels = Array.from(new Set([...currentPRLabels, ...issueLabels]));
82+
83+
await github.rest.issues.addLabels({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
issue_number: prNumber,
87+
labels: combinedLabels
88+
});
89+
console.log(`Labels applied: ${combinedLabels.join(', ')}`);
90+
91+
// --- Sync Milestone ---
92+
if (issue.milestone) {
93+
await github.rest.issues.update({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
issue_number: prNumber,
97+
milestone: issue.milestone.number
98+
});
99+
console.log(`Milestone synced: ${issue.milestone.title}`);
100+
}
101+
102+
// --- Sync Projects (GitHub Projects v2) ---
103+
if(issue.project_cards_url) {
104+
// Fetch project cards of issue
105+
const cardsResponse = await github.rest.projects.listCards({
106+
column_id: issue.project_cards_url.split('/').pop() // last part is column_id
107+
}).catch(()=>({data:[]}));
108+
109+
for(const card of cardsResponse.data || []) {
110+
await github.rest.projects.createCard({
111+
column_id: card.column_id,
112+
content_id: prNumber,
113+
content_type: 'PullRequest'
114+
});
115+
console.log(`Added PR #${prNumber} to project card in column ${card.column_id}`);
116+
}
117+
}
118+
119+
// --- Optionally: Add a comment on PR ---
120+
await github.rest.issues.createComment({
121+
owner: context.repo.owner,
122+
repo: context.repo.repo,
123+
issue_number: prNumber,
124+
body: `✅ Synchronized metadata from Issue #${issueNumber}:\nLabels: ${issueLabels.join(', ')}\nMilestone: ${issue.milestone ? issue.milestone.title : 'None'}`
125+
});
126+
127+
} catch (error) {
128+
console.error(`Error syncing issue #${issueNumber} to PR #${prNumber}:`, error.message);
129+
}
130+
}

.github/workflows/autolabler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
await github.rest.issues.addLabels({
2525
...context.repo,
2626
issue_number: prNumber,
27-
labels: ["recode", "level 1", "hacktoberfest-accepted"]
27+
labels: ["recode","hacktoberfest-accepted"]
2828
});
2929
30-
console.log(`Added labels [recode, level 1, hacktoberfest-accepted] to PR #${prNumber}`);
30+
console.log(`Added labels [recode, hacktoberfest-accepted] to PR #${prNumber}`);
3131
3232
- name: Add labels to Issue
3333
if: github.event_name == 'issues'

.github/workflows/lint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Lint
2+
on: [push, pull_request]
3+
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version: 20
12+
- run: npm ci
13+
- run: npm run lint

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ yarn-error.log*
2222
.env
2323
.cursorrule
2424

25-
package-lock.json
26-
2725
# Temporary files
28-
/tmp/
26+
/tmp/

.husky/prepare-commit-msg

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"singleQuote": false,
33
"semi": true,
44
"tabWidth": 2,
5-
"printWidth": 80
5+
"printWidth": 80,
6+
"plugins": ["prettier-plugin-tailwindcss"]
67
}

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS builder
22

33
WORKDIR /app
44

55
COPY package*.json ./
66

7+
# Install sharp dependencies
8+
RUN apk add --no-cache \
9+
g++ \
10+
make \
11+
python3 \
12+
libc6-compat
13+
14+
# Update npm to the latest version
15+
RUN npm install -g npm@latest
16+
717
RUN npm install --legacy-peer-deps
818

919
COPY . .
1020

11-
# No need to run 'npm run build' for development-mode Docker
21+
# Expose the application port
1222
EXPOSE 3000
1323

14-
CMD [ "npm", "run", "dev" ]
24+
# Start the application
25+
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
382 KB
Loading

0 commit comments

Comments
 (0)