diff --git a/.github/scripts/assets_folder.sh b/.github/scripts/assets_folder.sh index f32f4fb5c..408b1df13 100755 --- a/.github/scripts/assets_folder.sh +++ b/.github/scripts/assets_folder.sh @@ -1,46 +1,58 @@ #!/bin/bash -list_dir () { - find ../assets/ -maxdepth 1 -type d -exec echo "$1" \; > "$2" +make_file () { + file_name=ModsList.md + touch $file_name + { + echo "# 模組清單" + echo "" + echo "此清單用於記錄模組翻譯回饋回該模組專案的記錄" + echo "" + echo "| 模組名稱 | 貢獻 | PR | 翻譯變動 |" + echo "| ------ | ------ | ------ | ------ |" + } > $file_name } -readme_generate () { - file_name=readme_result.md - list_dir '
  • {}
  • ' $file_name - sed -i "s+
  • ../assets/
  • ++" $file_name - sed -i "s+
  • ../assets/minecraft
  • ++" $file_name - sed -i "s+../assets/++" $file_name - sed -i "/^$/d" $file_name +list_dir () { + find assets/ -maxdepth 1 -type d -exec echo "$1" \; >> "$2" } modslist_generate () { - file_name=modslist_result.md - list_dir '| {} | :x: | | |' $file_name - sed -i "1s+| ../assets/ | :x: | | |++" $file_name - sed -i "s+| {} | ../assets/minecraft | :x: | | |++" $file_name - sed -i "s+../assets/++" $file_name - sed -i "/^$/d" $file_name + file_name=modslist_result.md + list_dir '| {} | :x: | | |' $file_name + sed -i "1s+| assets/ | :x: | | |++" $file_name + sed -i "s+assets/++" $file_name + sed -i "/^$/d" $file_name } modslist_added_mod_generate () { - file_name=modslist_result.md - x_placeholder=" | :x: | | |" - question_placeholder=" | :question: |" - check_placeholder=" | :heavy_check_mark: |" - - if [ "$1" = 1 ]; then - sed -i "s+$2$x_placeholder+$2$check_placeholder [已回饋]($3) | |+" $file_name - elif [ "$1" = 2 ]; then - sed -i "s+$2$x_placeholder+$2$check_placeholder [已回饋]($3) | :heavy_exclamation_mark: |+" $file_name - elif [ "$1" = 3 ]; then - sed -i "s+$2$x_placeholder+$2$question_placeholder [等待合併]($3) | |+" $file_name - elif [ "$1" = 4 ]; then - sed -i "s+$2$x_placeholder+$2$question_placeholder 已提交上 Crowdin(或同步) | |+" $file_name - fi + file_name=modslist_result.md + x_placeholder=" | :x: | | |" + question_placeholder=" | :question: |" + check_placeholder=" | :heavy_check_mark: |" + + if [ "$1" = 1 ]; then + sed -i "s+$2$x_placeholder+$2$check_placeholder [已回饋]($3) | |+" $file_name + elif [ "$1" = 2 ]; then + sed -i "s+$2$x_placeholder+$2$check_placeholder [已回饋]($3) | :heavy_exclamation_mark: |+" $file_name + elif [ "$1" = 3 ]; then + sed -i "s+$2$x_placeholder+$2$question_placeholder [等待合併]($3) | |+" $file_name + elif [ "$1" = 4 ]; then + sed -i "s+$2$x_placeholder+$2$question_placeholder Crowdin | |+" $file_name + fi +} + +sort_file () { + sort -o modslist_result_sorted.md modslist_result.md +} + +combind_file () { + cat modslist_result_sorted.md >> ModsList.md + mv ModsList.md docs/ModsList.md + rm modslist_result_sorted.md modslist_result.md } # Main -readme_generate modslist_generate ## Status Code @@ -73,17 +85,26 @@ modslist_added_mod_generate "2" "fluxnetworks" "https://github.com/SonarSonic/Fl modslist_added_mod_generate "1" "yet-another-config-lib" "https://github.com/isXander/YetAnotherConfigLib/pull/31" ### ExNihiloSequentia -modslist_added_mod_generate "3" "exnihiloae" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" -modslist_added_mod_generate "3" "exnihilomekanism" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" -modslist_added_mod_generate "3" "exnihilosequentia" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" -modslist_added_mod_generate "3" "exnihilothermal" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" -modslist_added_mod_generate "3" "exnihilotinkers" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" +modslist_added_mod_generate "1" "exnihiloae" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" +modslist_added_mod_generate "1" "exnihilomekanism" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" +modslist_added_mod_generate "1" "exnihilosequentia" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" +modslist_added_mod_generate "1" "exnihilothermal" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" +modslist_added_mod_generate "1" "exnihilotinkers" "https://github.com/NovaMachina-Mods/ExNihiloSequentia/pull/380" ### LanguageReload -modslist_added_mod_generate "3" "languagereload" "https://github.com/Jerozgen/LanguageReload/pull/20" +modslist_added_mod_generate "1" "languagereload" "https://github.com/Jerozgen/LanguageReload/pull/20" ### BorderlessMining modslist_added_mod_generate "1" "borderlessmining" "https://github.com/comp500/BorderlessMining/pull/56" ### SlimefunToEMI modslist_added_mod_generate "3" "sftoemi" "https://github.com/JustAHuman-xD/SlimefunToEMI/pull/2" + +### CITResewn +modslist_added_mod_generate "1" "citresewn" "https://github.com/SHsuperCM/CITResewn/pull/219" +modslist_added_mod_generate "1" "citresewn-defaults" "https://github.com/SHsuperCM/CITResewn/pull/219" + +# Finish +sort_file +make_file +combind_file diff --git a/.github/workflows/ModsList-Updater.yml b/.github/workflows/ModsList-Updater.yml new file mode 100644 index 000000000..61243fb4f --- /dev/null +++ b/.github/workflows/ModsList-Updater.yml @@ -0,0 +1,47 @@ +name: ModsList Updater + +on: + workflow_dispatch: {} + schedule: + - cron: "0 0 * * 1" + +permissions: + contents: write + pull-requests: write + +jobs: + Updater: + name: ModsList docs updater + runs-on: ubuntu-latest + + steps: + - name: Checking Repostiory + uses: actions/checkout@v3 + + - name: Run script + run: ./.github/scripts/assets_folder.sh + + - name: Date + id: date + run: | + echo "date=$(date)" >> $GITHUB_OUTPUT + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + branch: "docs/action-modslist" + commit-message: "docs(ModsList): 更新模組清單" + title: "docs(ModsList): 更新模組清單" + body: | + 自動化 [GitHub Action][github-action] 更新模組清單文件。 + 產生時間:${{ steps.date.outputs.date }} + + ------ + 由 [create-pull-request][cpr] 製作 + + [cpr]: https://github.com/peter-evans/create-pull-request + [github-action]: https://github.com/features/actions + labels: | + 📃 文件