-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into recipes-slider
- Loading branch information
Showing
272 changed files
with
5,557 additions
and
961 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const fs = require("fs"); | ||
|
||
const addedContent = fs | ||
.readFileSync("added-content.txt") | ||
.toString() | ||
.split("\n"); | ||
|
||
if ( | ||
addedContent.length === 0 || | ||
(addedContent.length > 0 && addedContent[0] === "") | ||
) { | ||
return; | ||
} | ||
|
||
const currentDate = new Date(); | ||
const currentYear = currentDate.getFullYear(); | ||
const monthNames = [ | ||
"Январь", | ||
"Февраль", | ||
"Март", | ||
"Апрель", | ||
"Май", | ||
"Июнь", | ||
"Июль", | ||
"Август", | ||
"Сентябрь", | ||
"Октябрь", | ||
"Ноябрь", | ||
"Декабрь", | ||
]; | ||
const currentMonth = monthNames[currentDate.getMonth()]; | ||
const header = `## ${currentMonth} ${currentYear}`; | ||
|
||
const contentList = addedContent.map((fileName) => { | ||
if (fs.existsSync(fileName)) { | ||
const url = `https://doka.guide/${fileName.replace("index.md", "")}`; | ||
const date = process.argv[2]; | ||
|
||
const content = fs.readFileSync(fileName).toString(); | ||
|
||
const title = content | ||
.match(/title: ('|"|).*('|"|)\n/)[0] | ||
.replace(/title: ('|"|)/, "") | ||
.replace(/('|"|)\n/, ""); | ||
|
||
const authorsSelection = | ||
/authors:\n( - .*\n)+(contributors|cover|editors|keywords|related|tags):/; | ||
const authors = content | ||
.match(authorsSelection)[0] | ||
.split("\n") | ||
.slice(1, -1) | ||
.map((s) => s.replace(" - ", "")) | ||
.map((a) => { | ||
const authorFileName = `./people/${a}/index.md`; | ||
if (fs.existsSync(authorFileName)) { | ||
return fs | ||
.readFileSync(authorFileName) | ||
.toString() | ||
.match(/name: ('|"|).*('|"|)\n/)[0] | ||
.replace(/name: ('|"|)/, "") | ||
.replace(/('|"|)\n/, ""); | ||
} | ||
return authorFileName; | ||
}); | ||
|
||
return `- ${date}, [${title}](${url}), ${authors.join(", ")}`; | ||
} | ||
}); | ||
|
||
if (contentList.length > 0) { | ||
const changelogFileName = "./CHANGELOG.md"; | ||
if (fs.existsSync(changelogFileName)) { | ||
const changelog = fs.readFileSync(changelogFileName).toString().split("\n"); | ||
if (changelog.filter((s) => s.startsWith("## ")).includes(header)) { | ||
const headerPosition = changelog.findIndex((s) => s === header); | ||
changelog.splice(headerPosition + 2, 0, ...contentList); | ||
} else { | ||
const headerPosition = 4; | ||
changelog.splice(headerPosition, 0, ...[header, "", ""]); | ||
changelog.splice(headerPosition + 2, 0, ...contentList); | ||
} | ||
fs.writeFileSync(changelogFileName, changelog.join("\n")); | ||
console.log("Записи добавлены в CHANGELOG.md"); | ||
} | ||
} else { | ||
console.log("Нечего добавлять в CHANGELOG.md"); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
git diff --name-status HEAD^ HEAD | grep '^A' | grep -E '(html|css|js|tools|a11y|recipes)\/.*\/index\.md' | sed 's/^A\t//g' > added-content.txt | ||
|
||
if [ -s added-content.txt ]; then | ||
MONTH_TO_RUS() { | ||
case "$1" in | ||
01) echo "января" ;; | ||
02) echo "февраля" ;; | ||
03) echo "марта" ;; | ||
04) echo "апреля" ;; | ||
05) echo "мая" ;; | ||
06) echo "июня" ;; | ||
07) echo "июля" ;; | ||
08) echo "августа" ;; | ||
09) echo "сентября" ;; | ||
10) echo "октября" ;; | ||
11) echo "ноября" ;; | ||
12) echo "декабря" ;; | ||
esac | ||
} | ||
|
||
MERGE_DATE=$(date -u +"%d %m") | ||
DAY=$(echo $MERGE_DATE | cut -d ' ' -f 1) | ||
MONTH=$(echo $MERGE_DATE | cut -d ' ' -f 2) | ||
RUS_MONTH=$(MONTH_TO_RUS $MONTH) | ||
FORMATTED_DATE="$DAY $RUS_MONTH" | ||
|
||
node .github/scripts/update-changelog.js "$FORMATTED_DATE" | ||
|
||
rm -f added-content.txt | ||
|
||
if [[ -z $(git status -s) ]] | ||
then | ||
echo $(git status) | ||
else | ||
git config --global user.name "Doka Dog" | ||
git config --global user.email "<[email protected]>" | ||
|
||
git add CHANGELOG.md | ||
git commit -m "Обновляет CHANGELOG" --author "Doka Dog <[email protected]>" | ||
|
||
git pull --rebase | ||
git push origin main | ||
|
||
exit | ||
fi | ||
else | ||
echo "Новых материалов не было в предыдущем коммите" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Update CHANGELOG | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- "Frontmatter Lint" | ||
branches: | ||
- main | ||
types: | ||
- completed | ||
|
||
concurrency: | ||
group: Update CHANGELOG | ||
|
||
jobs: | ||
update_changelog: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.DOKA_BOT_ACCESS_TOKEN }} | ||
fetch-depth: 2 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Ищет новые материалы и обновляет CHANGELOG | ||
run: sh .github/scripts/update-changelog.sh |
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
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"createdAt": "2024-06-17T11:25:33.033Z", | ||
"updatedAt": "2024-06-17T11:25:33.033Z" | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"createdAt": "2024-04-24T21:51:03.970Z", | ||
"updatedAt": "2024-04-24T21:51:03.970Z" | ||
"updatedAt": "2024-06-27T08:42:31.171Z" | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"createdAt": "2024-06-17T11:25:33.033Z", | ||
"updatedAt": "2024-07-03T19:50:31.006Z" | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"createdAt": "2024-04-12T14:49:27.614Z", | ||
"updatedAt": "2024-04-12T14:49:27.614Z" | ||
"updatedAt": "2024-07-03T19:50:31.006Z" | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"createdAt": "2024-06-17T11:21:46.176Z", | ||
"updatedAt": "2024-06-17T11:40:04.090Z" | ||
} |
Oops, something went wrong.