-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: add pr langauge labeler * rename job * apply reviews (Integrate into integration workflow) * Rename job
- Loading branch information
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,77 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: fernandrone/[email protected] | ||
|
||
label-lang: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Create package.json | ||
run: echo '{}' > package.json | ||
|
||
- name: Install dependencies | ||
run: npm install @octokit/rest node-fetch | ||
|
||
- name: Detect languages and add labels | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
PR_NUM: ${{ github.event.number }} | ||
run: | | ||
node --input-type=module -e " | ||
import { Octokit } from '@octokit/rest'; | ||
import path from 'path'; | ||
import fetch from 'node-fetch'; | ||
const octokit = new Octokit({ | ||
auth: process.env.GITHUB_TOKEN, | ||
request: { fetch } | ||
}); | ||
const extensionsToLanguages = { | ||
js: 'js', | ||
ts: 'ts', | ||
py: 'py', | ||
java: 'java', | ||
kt: 'kotlin', | ||
cpp: 'c++', | ||
go: 'go', | ||
exs: 'elixir', | ||
swift: 'swift' | ||
// ํ์ํ ๋ค๋ฅธ ํ์ฅ์์ ์ธ์ด ๋งคํ ์ถ๊ฐ | ||
}; | ||
async function run() { | ||
const { data: files } = await octokit.pulls.listFiles({ | ||
owner: process.env.GITHUB_REPOSITORY.split('/')[0], | ||
repo: process.env.GITHUB_REPOSITORY.split('/')[1], | ||
pull_number: process.env.PR_NUM, | ||
}); | ||
const languages = new Set(); | ||
files.forEach(file => { | ||
const ext = path.extname(file.filename).slice(1); | ||
if (extensionsToLanguages[ext]) { | ||
languages.add(extensionsToLanguages[ext]); | ||
} | ||
}); | ||
if (languages.size > 0) { | ||
await octokit.issues.addLabels({ | ||
owner: process.env.GITHUB_REPOSITORY.split('/')[0], | ||
repo: process.env.GITHUB_REPOSITORY.split('/')[1], | ||
issue_number: process.env.PR_NUM, | ||
labels: Array.from(languages), | ||
}); | ||
} | ||
} | ||
run().catch(err => console.error(err)); | ||
" |