Skip to content

Commit

Permalink
ci: add codeql and vercel actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Dec 15, 2023
1 parent b24ab73 commit b379447
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CodeQL

on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '14 8 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language:
- javascript

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:${{ matrix.language }}'
30 changes: 30 additions & 0 deletions .github/workflows/vercel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Vercel Deploy

on:
push:
branches:
- master
pull_request_target: null

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check Branch
id: branch
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "args=--prod" >> $GITHUB_OUTPUT
echo "comment=false" >> $GITHUB_OUTPUT
- name: Deploy
uses: amondnet/vercel-action@v25
with:
vercel-args: ${{ steps.branch.outputs.args }}
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
github-comment: ${{ steps.branch.outputs.comment != 'false' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion api/_deeplx.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const SUPPORTED_LANGUAGES = [
{ code: "SK", language: "Slovak" },
{ code: "SL", language: "Slovenian" },
{ code: "ES", language: "Spanish" },
{ code: "SV", language: "Swedish" }
{ code: "SV", language: "Swedish" },
{ code: "TR", language: "Turkish" }
];
const SUPPORTED_FORMALITY_TONES = ["formal", "informal"];

Expand Down Expand Up @@ -204,6 +205,10 @@ function requestTranslation(text, targetLanguage, sourceLanguage, identifier, al
function translate(_0, _1) {
return __async(this, arguments, function* (text, targetLanguage, sourceLanguage = AUTO, identifier, alternatives, formalityTone) {
var _a;
text = text == null ? void 0 : text.trim();
if (!text) {
return text;
}
return extractTranslatedSentences(yield requestTranslation(text, abbreviateLanguage(targetLanguage), (_a = abbreviateLanguage(sourceLanguage)) != null ? _a : "auto", identifier, alternatives, formalityTone)).join(" ");
});
}
Expand Down

0 comments on commit b379447

Please sign in to comment.