Next 15 + Repo refresh #626
Workflow file for this run
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
name: "Notify codeowners about changes in docs" | |
on: | |
pull_request_target: | |
types: [opened, edited, synchronize] | |
branches: | |
- "*" | |
paths: | |
- "www/src/pages/**" | |
- "!www/src/pages/en/**" | |
jobs: | |
notify-codeowners: | |
if: | | |
github.repository_owner == 't3-oss' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Parse changed files and write to env | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const changedFiles = (await github.rest.pulls.listFiles({ | |
owner: "t3-oss", | |
repo: "create-t3-app", | |
pull_number: context.payload.number, | |
})).data.map(file => file.filename); | |
const changedLanguages = [ | |
...new Set( | |
changedFiles | |
.filter((file) => file.startsWith("www/src/pages/")) | |
.map((file) => file.split("/")[3]) | |
.filter((file) => file !== "en"), | |
), | |
]; | |
const CODEOWNERS = { | |
ar: ["a4addel", "Sboonny"], | |
fr: ["Defranos", "joachimjusth", "vdeva"], | |
ja: ["t6adev", "uehaj"], | |
no: ["estubmo", "josephayman"], | |
pl: ["matibox", "Infiplaya", "PiotrekPKP"], | |
pt: ["minsk-dev", "Sn0wye", "victoriaquasar", "MattFerreira18", "gilhrpenner"], | |
ru: ["AmadeusTwi", "ronanru", "JohnBakhmat"], | |
uk: ["pqoqubbw"], | |
"zh-hans": ["fernandoxu", "escwxyz"], | |
}; | |
console.log("Changed languages:", changedLanguages) | |
const formattedString = changedLanguages | |
.map( | |
(lang) => | |
`${lang.toUpperCase()}: ${(CODEOWNERS[lang] || []).map((user) => `@${user}`).join(", ")}`, | |
) | |
.join(" | "); // cause we can't linebreak in env vars | |
console.log("Formatted string:", formattedString) | |
require("fs").appendFileSync( | |
process.env.GITHUB_ENV, | |
`\nCODEOWNERS=${formattedString}`, | |
); | |
- name: Write comment on the PR tagging codeowners | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
number: ${{ env.WORKFLOW_RUN_PR }} | |
message: | | |
Hey t3-oss/translators! | |
This PR contains changes to your language. Please review the changes ❤️. | |
${{ env.CODEOWNERS }} |