2021-01-21 03:28:19 +07:00
name : UncivBot
2021-01-24 04:47:11 +07:00
on :
issue_comment :
workflow_dispatch :
2021-01-21 03:28:19 +07:00
jobs :
Move wiki pages into repository, fix dozens of broken links. (#5854)
* Updated Mods (markdown)
* Updated Scenarios (markdown)
* Updated Mods (markdown)
* Added itch.io release
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Project structure and major classes (markdown)
* Updated Mods (markdown)
* Created Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Added link to Uniques
* Updated Uniques (markdown)
* Added 'triggers victory' unique
* Updated Making a new Civilization (markdown)
* Created Building locally without Android Studio (markdown)
* Updated Translating (markdown)
* Updated Uniques (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Uniques (markdown)
* Added improvement uniques
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* I thought a tutorial on how to create a custom tileset in the first place could not hurt
* Moved the sentence to the "Creating a custom tileset" page
* Updated Making a new Civilization (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Destroyed Scenarios (markdown)
* Updated Uniques (markdown)
* Changed Travis documentation to Github actions documentation
* Updated Translating (markdown)
* Updated Translating (markdown)
* Updated From code to deployment (markdown)
* Removed "working on templated rule variants" because we currently don't
* Updated Uniques (markdown)
* Updated uniques based on everything done during the policy update
* Misplaced a unique
* Updated Making a new Civilization (markdown)
* Updated Making a new Civilization (markdown)
* Updated Translating (markdown)
* Updated Uniques (markdown)
* Removed [pending] messages for PR's that were no longer pending
* Added uniques from telecommuncations/advanced balistics
* Added all the uniques from my PR's (telecommunicatoins -- shrines); added uniques I deprecated at some point
* Updated Uniques (markdown)
* Added missing deprecated unique
* Added uniques changed in #4292
* Updated Uniques (markdown)
* Added uniques from #4311 and #4301
* Added uniques from #4331
* Added Discord webhook message
* Created page with basic information
* Typo
* Made information not incorrect
* Added units.json
* Manual new lines was a terrible idea
* Updated JSON files for mods (markdown)
* Added link to JSON files for mods explanation
* Added eras.json
* capitalization
* Added a header
* Improved example
* Added Buildings.json
* hmmm
* Doesn't work, sad
* Added information on Specialists.json
* Updated JSON files for mods (markdown)
* Added uniques from #4372
* Updated Uniques (markdown)
* Updated uniques after #4393
* Updated uniques after #4423
* Add new and deprecated uniques of #4487, #4459
* add wonder images
* Fixed mod directory
* Updated Uniques (markdown)
* Updated uniques after #4530, #4505, #4419
* Reworked the passages on tileFilter, terrainFilter and improvementFilter from code inspection
* Added a more indept guide on how to install UnCiv on macOS
* Updated Uniques (markdown)
* Created Credits.md (markdown)
* Destroyed Credits.md (markdown)
* Added installing from source method
* Improve Sound chapter, added Civilopedia text chapter
* Added after #4619
* Added unitTypes.json
* Added beliefs.json
* Updated Translating (markdown)
* Added eras:unitBaseBuyCost
* Added after #4568
* Added ruins.json
* Added after #4771
* Added rudimentary Difficulties.json doc
* Added ruin-specfic uniques explanation
* Added TOC and Nations
* Detailed Techs chapter
* Fix 1 line - tech uniques
* Added Quests.json
* Added ModOptions
* Added ModOptions
* Added UnitPromotions, structured TOC
* Added Policies
* Added crosslinks
* Fixed broken links
* Added TileResources
* Added more crosslinks
* Small fix resource tile graphix aren't toggle-able
* Added TileImprovements
* Added Terrains
* Updated JSON files for mods (markdown)
* Updated Getting Started (markdown)
* Updated Getting Started (markdown)
* Updated Getting Started (markdown)
* Updated JSON files for mods (markdown)
* Updated Translating (markdown)
* Created Civilization-related JSON files (markdown)
* Created Map-related JSON files (markdown)
* Double title
* Double title
* Created Unit-related JSON files (markdown)
* Moved sounds
* Updated Unit related JSON files (markdown)
* Moved Stats
* Created Miscellaneous JSON files (markdown)
* Removed content that has been moved to separate pages, update TOC
* Created _Sidebar (markdown)
* Updated Uniques (markdown)
* test
* Fixed broken links. Apparently the way 'preview' links to pages differs from how it links when you view them on a saved page for some reason
* Updated Uniques (markdown)
* Fix relative `..` link suddenly leaving the wiki
* Updated Miscellaneous JSON files (markdown)
* Fix relative links
* Fix era links to Units.json
* Updated Uniques (markdown)
* Updated From code to deployment (markdown)
* Added uniques & cityFilters up to #4995
* Mass deprecation as per 422607
* Fixed broken link to redirect to Unit Uniques in Wiki
* Fixed broken link to redirect to Unit Uniques in Wiki table
* Updated Uniques (markdown)
* Updated Getting Started (markdown)
* Updated Uniques (markdown)
* Added uniques & filters up to #5094
* Removed a deprecated unique
* Moved some uniques to better sections, removed an outdated unique
* fixed a typo
* Updated Uniques (markdown)
* eras.json is now required
* Removed outdated religion section
* Added missing terrain uniques
* Added resource uniques
* Fixed resource unique link
* Added missing unique for tile improvements
* Fixed broken link
* "Disappearing" translations explained
* Updated Home (markdown)
* Some atlas info, leader portraits
* Created Force rating calculation (markdown)
* "Not yet" for Image atlas distribution in mods
* Updated uniques after #5259
* Added information on conditionals
* Updated growth unique
* Added conditional support up to #5270
* Typo
* Escape html tags
* Add conditionals to table of contents
* Updated _Sidebar (markdown)
* Created Audiovisual Mods (markdown)
* Audiovisual Mods, move Graphics-only info
* Updated Audiovisual Mods (markdown)
* Audiovisual Mods - Draft done.
* Documented translation method
* Updated Translations, mods, and modding freedom in Open Source (markdown)
* Fix Typos and Links
* New Terrain uniques / 2 sections
* Atlas control via multiple Images.x folders is now live
* Link to atlas paragraph
* startBias clarification
* Missing bracket
* Added uniques & conditionals up to #5345 (my PR's only)
* Updated Force rating calculation (markdown)
* Updated Getting Started (markdown => asciidoc)
* Undid renaming
* Updated Getting Started (asciidoc => markdown)
* Added fix for Gradle sync fail
* Updated Project structure and major classes (markdown)
* Bump Java version from JDK 8 to JDK 11 due to gradle upgrade
* Updated uniques & conditionals up to #5618 from my PR's
* Created Regions (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Mention docs/uniques.md, emphasized Stat capitalization
* Move wiki files into `/docs/wiki`.
* Migrate inter-Markdown links.
* Fix pre-existing broken links and anchors.
* Standardize repository links for AS linting.
* Add wiki footer.
* Updated Uniques (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Making a new Civilization (markdown)
* Add GH Action for updating wiki.
* Play it safer, and don't `push -f`. (Should be the same either way though.)
Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
Co-authored-by: GGGuenni <leonard@eynck.de>
Co-authored-by: Xander Lenstra <71121390+xlenstra@users.noreply.github.com>
Co-authored-by: Martin Pechstein <77325495+Mape6@users.noreply.github.com>
Co-authored-by: Arthur van der Staaij <32672293+avdstaaij@users.noreply.github.com>
Co-authored-by: SimonCeder <63475501+SimonCeder@users.noreply.github.com>
Co-authored-by: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com>
Co-authored-by: Alex25820 <50142558+Alex25820@users.noreply.github.com>
Co-authored-by: jvy1001 <76390095+jvy1001@users.noreply.github.com>
Co-authored-by: Shann Aurelle Ripalda <shannaurelleg@gmail.com>
Co-authored-by: NxOne14 <81563289+NxOne14@users.noreply.github.com>
Co-authored-by: MenaKing2020 <92416577+MenaKing2020@users.noreply.github.com>
Co-authored-by: asda488 <39116917+asda488@users.noreply.github.com>
2022-01-24 02:49:43 +07:00
update_wiki :
if : github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == 'update wiki' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
# This is the only place I could find an apparent list of valid author associations: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
runs-on : ubuntu-latest
steps :
- name : Update Wiki.
id : update
continue-on-error : true
env :
GH_TOKEN : ${{ secrets.ACTIONS_ACCESS_TOKEN }}
CODE_DIR : CodeRepo
WIKI_DIR : WikiRepo
WIKI_IN_CODE_REPO : /docs/wiki
EVENT_CONTEXT : ${{ toJSON(github) }}
# Dump for debug.
PR_MERGEDAT : ${{ toJSON(github.event.issue.pull_request.merged_at) }}
# The environment variable isn't set for `null`, so stringify.
PR_AUTHOR : ${{ github.event.issue.user.login }}
# I think directly putting these in the script would let quotes in PR title break the script. Set environment variables so Bash can take care of the substitution.
PR_TITLE : ${{ github.event.issue.title }}
PR_NUMBER : ${{ github.event.issue.number }}
PR_URL : ${{ github.event.issue.html_url }}
# Compare to https://github.com/SwiftDocOrg/github-wiki-publish-action/blob/v1/entrypoint.sh
# May also be some value in replacing `echo` for logging with some more structured GH Action commands: https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
run : |
#echo "$EVENT_CONTEXT" # Dump entire event to logs. Watch out for leaks.
set -euo pipefail # Immediate exit on command errors and unset variables.
#set -x # Print out each executed command. THIS MAY LEAK THE PERSONAL ACCESS TOKEN SECRET VIA $GH_TOKEN and $WIKI_URL (though AFAICT GH is sanitizing it)!
function ghEnvVar() {
GHENV_DELIMITER="#GH-EOF_$(date +%s)-$RANDOM!"
echo "$1<<$GHENV_DELIMITER" >> $GITHUB_ENV
echo "$2" >> $GITHUB_ENV
echo "$GHENV_DELIMITER" >> $GITHUB_ENV
# This sets an environment variable for subsequent GH Action steps.
}
ghEnvVar WIKIBOT_STATUS ""
ghEnvVar WIKIBOT_CHANGES ""
function ghStatus() {
echo $@
ghEnvVar WIKIBOT_STATUS "$@"
}
for REQUIRED_ENV_VAR in GITHUB_ENV GITHUB_ACTOR GITHUB_SERVER_URL GITHUB_REPOSITORY GH_TOKEN CODE_DIR WIKI_DIR WIKI_IN_CODE_REPO PR_MERGEDAT PR_AUTHOR PR_TITLE PR_NUMBER PR_URL; do
if [ -z "$(eval "echo \$$REQUIRED_ENV_VAR")" ]; then
ghStatus "ERROR: \$$REQUIRED_ENV_VAR is not set."
exit 1
fi
done
if [ "${PR_MERGEDAT}" = 'null' ]; then
ghStatus "ERROR: Pull request must be merged."
exit 1
fi
CODE_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
WIKI_URL="https://${GH_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.wiki.git"
ghStatus "Cloning repository: $CODE_URL"
git clone "$CODE_URL" "$CODE_DIR"
ghStatus "Cloning Wiki."
git clone "$WIKI_URL" "$WIKI_DIR"
ghStatus 'Running `rsync`.'
rsync -avc --delete --exclude '.git*' "${CODE_DIR}${WIKI_IN_CODE_REPO}/" "$WIKI_DIR/"
# …The trailing slashes here are very important! Otherwise it will copy/target the directory, instead of its contents.
ghStatus "Formatting Markdown files in $WIKI_DIR."
cd "$WIKI_DIR"
for f in *.md; do
if [ -e "$f" ]; then
ghStatus "Formatting $f links."
# Convert AS/GH code browser inter-page links to GH Wiki links by stripping `.md` extensions.
sed -ie 's|\(](\./[^)]*\)\.md|\1|g' "$f"
# Convert AS/GH code browser repo file links to GH Wiki links by prepending repo browser to absolute links.
2022-01-25 05:06:19 +07:00
sed -ie 's|](/|](https://github.com/'"${GITHUB_REPOSITORY}"'/tree/master/|g' "$f"
Move wiki pages into repository, fix dozens of broken links. (#5854)
* Updated Mods (markdown)
* Updated Scenarios (markdown)
* Updated Mods (markdown)
* Added itch.io release
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Project structure and major classes (markdown)
* Updated Mods (markdown)
* Created Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Added link to Uniques
* Updated Uniques (markdown)
* Added 'triggers victory' unique
* Updated Making a new Civilization (markdown)
* Created Building locally without Android Studio (markdown)
* Updated Translating (markdown)
* Updated Uniques (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Uniques (markdown)
* Added improvement uniques
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Mods (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* I thought a tutorial on how to create a custom tileset in the first place could not hurt
* Moved the sentence to the "Creating a custom tileset" page
* Updated Making a new Civilization (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Destroyed Scenarios (markdown)
* Updated Uniques (markdown)
* Changed Travis documentation to Github actions documentation
* Updated Translating (markdown)
* Updated Translating (markdown)
* Updated From code to deployment (markdown)
* Removed "working on templated rule variants" because we currently don't
* Updated Uniques (markdown)
* Updated uniques based on everything done during the policy update
* Misplaced a unique
* Updated Making a new Civilization (markdown)
* Updated Making a new Civilization (markdown)
* Updated Translating (markdown)
* Updated Uniques (markdown)
* Removed [pending] messages for PR's that were no longer pending
* Added uniques from telecommuncations/advanced balistics
* Added all the uniques from my PR's (telecommunicatoins -- shrines); added uniques I deprecated at some point
* Updated Uniques (markdown)
* Added missing deprecated unique
* Added uniques changed in #4292
* Updated Uniques (markdown)
* Added uniques from #4311 and #4301
* Added uniques from #4331
* Added Discord webhook message
* Created page with basic information
* Typo
* Made information not incorrect
* Added units.json
* Manual new lines was a terrible idea
* Updated JSON files for mods (markdown)
* Added link to JSON files for mods explanation
* Added eras.json
* capitalization
* Added a header
* Improved example
* Added Buildings.json
* hmmm
* Doesn't work, sad
* Added information on Specialists.json
* Updated JSON files for mods (markdown)
* Added uniques from #4372
* Updated Uniques (markdown)
* Updated uniques after #4393
* Updated uniques after #4423
* Add new and deprecated uniques of #4487, #4459
* add wonder images
* Fixed mod directory
* Updated Uniques (markdown)
* Updated uniques after #4530, #4505, #4419
* Reworked the passages on tileFilter, terrainFilter and improvementFilter from code inspection
* Added a more indept guide on how to install UnCiv on macOS
* Updated Uniques (markdown)
* Created Credits.md (markdown)
* Destroyed Credits.md (markdown)
* Added installing from source method
* Improve Sound chapter, added Civilopedia text chapter
* Added after #4619
* Added unitTypes.json
* Added beliefs.json
* Updated Translating (markdown)
* Added eras:unitBaseBuyCost
* Added after #4568
* Added ruins.json
* Added after #4771
* Added rudimentary Difficulties.json doc
* Added ruin-specfic uniques explanation
* Added TOC and Nations
* Detailed Techs chapter
* Fix 1 line - tech uniques
* Added Quests.json
* Added ModOptions
* Added ModOptions
* Added UnitPromotions, structured TOC
* Added Policies
* Added crosslinks
* Fixed broken links
* Added TileResources
* Added more crosslinks
* Small fix resource tile graphix aren't toggle-able
* Added TileImprovements
* Added Terrains
* Updated JSON files for mods (markdown)
* Updated Getting Started (markdown)
* Updated Getting Started (markdown)
* Updated Getting Started (markdown)
* Updated JSON files for mods (markdown)
* Updated Translating (markdown)
* Created Civilization-related JSON files (markdown)
* Created Map-related JSON files (markdown)
* Double title
* Double title
* Created Unit-related JSON files (markdown)
* Moved sounds
* Updated Unit related JSON files (markdown)
* Moved Stats
* Created Miscellaneous JSON files (markdown)
* Removed content that has been moved to separate pages, update TOC
* Created _Sidebar (markdown)
* Updated Uniques (markdown)
* test
* Fixed broken links. Apparently the way 'preview' links to pages differs from how it links when you view them on a saved page for some reason
* Updated Uniques (markdown)
* Fix relative `..` link suddenly leaving the wiki
* Updated Miscellaneous JSON files (markdown)
* Fix relative links
* Fix era links to Units.json
* Updated Uniques (markdown)
* Updated From code to deployment (markdown)
* Added uniques & cityFilters up to #4995
* Mass deprecation as per 422607
* Fixed broken link to redirect to Unit Uniques in Wiki
* Fixed broken link to redirect to Unit Uniques in Wiki table
* Updated Uniques (markdown)
* Updated Getting Started (markdown)
* Updated Uniques (markdown)
* Added uniques & filters up to #5094
* Removed a deprecated unique
* Moved some uniques to better sections, removed an outdated unique
* fixed a typo
* Updated Uniques (markdown)
* eras.json is now required
* Removed outdated religion section
* Added missing terrain uniques
* Added resource uniques
* Fixed resource unique link
* Added missing unique for tile improvements
* Fixed broken link
* "Disappearing" translations explained
* Updated Home (markdown)
* Some atlas info, leader portraits
* Created Force rating calculation (markdown)
* "Not yet" for Image atlas distribution in mods
* Updated uniques after #5259
* Added information on conditionals
* Updated growth unique
* Added conditional support up to #5270
* Typo
* Escape html tags
* Add conditionals to table of contents
* Updated _Sidebar (markdown)
* Created Audiovisual Mods (markdown)
* Audiovisual Mods, move Graphics-only info
* Updated Audiovisual Mods (markdown)
* Audiovisual Mods - Draft done.
* Documented translation method
* Updated Translations, mods, and modding freedom in Open Source (markdown)
* Fix Typos and Links
* New Terrain uniques / 2 sections
* Atlas control via multiple Images.x folders is now live
* Link to atlas paragraph
* startBias clarification
* Missing bracket
* Added uniques & conditionals up to #5345 (my PR's only)
* Updated Force rating calculation (markdown)
* Updated Getting Started (markdown => asciidoc)
* Undid renaming
* Updated Getting Started (asciidoc => markdown)
* Added fix for Gradle sync fail
* Updated Project structure and major classes (markdown)
* Bump Java version from JDK 8 to JDK 11 due to gradle upgrade
* Updated uniques & conditionals up to #5618 from my PR's
* Created Regions (markdown)
* Updated Uniques (markdown)
* Updated Uniques (markdown)
* Mention docs/uniques.md, emphasized Stat capitalization
* Move wiki files into `/docs/wiki`.
* Migrate inter-Markdown links.
* Fix pre-existing broken links and anchors.
* Standardize repository links for AS linting.
* Add wiki footer.
* Updated Uniques (markdown)
* Updated Mods Making a new Civilization (markdown)
* Updated Making a new Civilization (markdown)
* Add GH Action for updating wiki.
* Play it safer, and don't `push -f`. (Should be the same either way though.)
Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
Co-authored-by: GGGuenni <leonard@eynck.de>
Co-authored-by: Xander Lenstra <71121390+xlenstra@users.noreply.github.com>
Co-authored-by: Martin Pechstein <77325495+Mape6@users.noreply.github.com>
Co-authored-by: Arthur van der Staaij <32672293+avdstaaij@users.noreply.github.com>
Co-authored-by: SimonCeder <63475501+SimonCeder@users.noreply.github.com>
Co-authored-by: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com>
Co-authored-by: Alex25820 <50142558+Alex25820@users.noreply.github.com>
Co-authored-by: jvy1001 <76390095+jvy1001@users.noreply.github.com>
Co-authored-by: Shann Aurelle Ripalda <shannaurelleg@gmail.com>
Co-authored-by: NxOne14 <81563289+NxOne14@users.noreply.github.com>
Co-authored-by: MenaKing2020 <92416577+MenaKing2020@users.noreply.github.com>
Co-authored-by: asda488 <39116917+asda488@users.noreply.github.com>
2022-01-24 02:49:43 +07:00
else # When glob produces no matches, you just get the glob pattern instead.
ghStatus "Skipping non-existent file $f."
fi
done
ghStatus "Finished formatting Markdown files."
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
ghStatus "Summarizing files."
tree
ghStatus "Adding files to Git."
git add .
ghStatus "Summarizing diff."
CHANGES="$(git diff --stat --cached | cat)" # IDK If Git might try to enter the interactive viewer without a pipe output. Probably not, but play it safe.
echo "$CHANGES"
ghEnvVar WIKIBOT_CHANGES "$CHANGES"
ghStatus "Committing changes."
git commit --allow-empty -m "@${PR_AUTHOR}: ${PR_TITLE} (#${PR_NUMBER})" -m "${PR_URL}"
ghStatus "Pushing changes."
git push # Since we just cloned the wiki repo anyway, it should also be safe to use -f.
#git push --set-upstream "$WIKI_URL" master # Should be the same since we cloned from the URL, just more explicit.
ghStatus "Done."
- name : Report Wiki update status.
id : report
continue-on-error : false
uses : actions/github-script@v3
env :
WIKIBOT_OUTCOME : ${{ steps.update.outcome }}
with :
github-token : ${{ secrets.GITHUB_TOKEN }}
script : |
const message = []
message.push(`Wiki update : ${process.env.WIKIBOT_OUTCOME}.`)
message.push("")
message.push("Status:")
message.push("```")
message.push(process.env.WIKIBOT_STATUS)
message.push("```")
message.push("")
message.push("Changes:")
message.push("```")
message.push(process.env.WIKIBOT_CHANGES)
message.push("```")
//message.push("\n<details><summary>Details</summary>\n\n```JSON\n" + JSON.stringify({context: context, github: github, core: core, glob: glob, io: io, process: process}, null, '\t') + '\n```\n</details>\n')
// Uncomment this for debug. But delete the bot comments on GH afterwards in case it leaks anything.
github.issues.createComment({
issue_number : context.issue.number,
owner : context.repo.owner,
repo : context.repo.repo,
body : message.join("\n")
})
if (process.env.WIKIBOT_OUTCOME != 'success') {
core.setFailed(`Failed at : ${process.env.WIKIBOT_STATUS}.`)
}
2022-03-09 18:45:39 +07:00
prepare_version_for_rollout :
if : github.event_name == 'issue_comment' && (github.event.comment.body == 'summary' || github.event.comment.body == 'prepare version') && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
2022-01-02 18:27:52 +07:00
# This is the only place I could find an apparent list of valid author associations. Also, at least they're not case-sensitive: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation https://docs.github.com/en/actions/learn-github-actions/expressions#contains
2021-01-21 03:28:19 +07:00
runs-on : ubuntu-latest
steps :
2022-03-09 01:28:14 +07:00
- uses : actions/checkout@v2
- uses : actions/setup-node@v2
2022-03-09 01:31:32 +07:00
- run : |
2022-03-09 01:42:31 +07:00
npm i @octokit/rest
2022-03-09 19:45:54 +07:00
node .github/workflows/incrementVersionAndChangelog.js
2022-03-09 16:42:42 +07:00
rm -rf node_modules # Now we need to remove extraneous node.js parts before commit
rm package-lock.json
2022-03-09 16:52:06 +07:00
rm package.json
2022-03-09 16:42:42 +07:00
2022-03-09 16:37:27 +07:00
- uses : EndBug/add-and-commit@v8 # You can change this to use a specific version.
with :
2022-03-09 18:45:39 +07:00
new_branch : version_rollout
2021-01-22 18:03:26 +07:00
2022-03-09 19:45:54 +07:00
- name : Add translation PRs to the new branch, and PR the new branch to master
run : |
npm i @octokit/rest
node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} version_rollout
2021-01-22 18:03:26 +07:00
merge_translations :
2022-01-02 18:27:52 +07:00
if : github.event_name == 'workflow_dispatch' || (github.event.comment.body == 'merge translations' && contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
# This is the only place I could find an apparent list of valid author associations. Also, at least they're not case-sensitive: https://docs.github.com/en/graphql/reference/enums#commentauthorassociation https://docs.github.com/en/actions/learn-github-actions/expressions#contains
2021-01-22 18:03:26 +07:00
runs-on : ubuntu-latest
steps :
- uses : actions/github-script@v3
with :
2021-01-25 00:22:36 +07:00
# SO, the story is that when using the default access token you CANNOT merge PRs from forks.
# _Badly_ documented in multiple places, including here: https://docs.github.com/en/actions/reference/authentication-in-a-workflow
# To get around this, we created a Personal Access Token,
# put it as one of the secrets in the repo settings (https://github.com/yairm210/Unciv/settings/secrets/actions),
# and use that instead.
2021-01-25 00:09:39 +07:00
github-token : ${{ secrets.ACTIONS_ACCESS_TOKEN }}
2021-01-22 18:03:26 +07:00
script : |
2021-01-25 00:31:58 +07:00
const repo = {
owner : context.repo.owner,
repo : context.repo.repo }
2021-01-22 18:03:26 +07:00
async function branchExists(branchName) {
try {
2021-01-25 00:31:58 +07:00
await github.git.getRef({...repo, ref: 'heads/' + branchName })
2021-01-22 18:03:26 +07:00
return true
} catch (err) {
return false
}
}
async function getDefaultBranch() {
2021-01-25 00:39:34 +07:00
var repoData = await github.repos.get(repo)
return repoData.data.default_branch
2021-01-22 18:03:26 +07:00
}
2021-01-24 00:28:46 +07:00
var translations = "translations"
2021-01-22 18:03:26 +07:00
2021-01-24 00:28:46 +07:00
async function createTranslationBranchIfNeeded() {
if (await branchExists(translations)) return
var defaultBranch = await getDefaultBranch()
2021-01-24 01:09:56 +07:00
2021-01-25 00:31:58 +07:00
var currentHead = await github.git.getRef({...repo, ref: 'heads/' + defaultBranch })
2021-01-24 01:09:56 +07:00
2021-01-24 00:28:46 +07:00
var currentSha = currentHead.data.object.sha
2021-01-24 00:35:04 +07:00
console.log("Current sha: " + currentSha)
2021-01-24 01:09:56 +07:00
2021-01-25 00:31:58 +07:00
await github.git.createRef({...repo,
2021-01-24 00:28:46 +07:00
ref : `refs/heads/`+translations,
2021-01-24 00:32:05 +07:00
sha : currentSha })
2021-01-24 01:09:56 +07:00
2021-01-25 00:31:58 +07:00
await github.issues.createComment({...repo,
2021-01-24 00:32:05 +07:00
issue_number : context.issue.number,
body : 'Translations branch created' })
2021-01-24 00:28:46 +07:00
}
2021-01-24 00:52:58 +07:00
async function mergeExistingTranslationsIntoBranch(){
2021-01-25 00:31:58 +07:00
var translationPrs = await github.pulls.list({ ...repo, state: "open" })
2021-01-24 01:09:56 +07:00
2021-01-25 00:22:36 +07:00
// When we used a forEach loop here, only one merge would happen at each run,
// because we essentially started multiple async tasks in parallel and they conflicted.
// Instead, we use X of Y as per https://stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop
for (const pr of translationPrs.data) {
2021-01-24 01:31:25 +07:00
if (pr.labels.some(label => label.name == "mergeable translation"))
2021-01-24 01:48:50 +07:00
await tryMergePr(pr)
2021-01-25 00:22:36 +07:00
}
2021-01-24 00:52:58 +07:00
}
2021-01-24 01:48:50 +07:00
async function tryMergePr(pr){
if (pr.base.ref != translations)
2021-01-25 00:31:58 +07:00
await github.pulls.update({ ...repo,
2021-01-24 01:48:50 +07:00
pull_number : pr.number,
base : translations })
2021-01-24 04:03:18 +07:00
try {
2021-01-25 00:31:58 +07:00
await github.pulls.merge({...repo,
2021-01-24 01:48:50 +07:00
pull_number : pr.number,
merge_method : "squash" })
2021-01-24 04:43:49 +07:00
console.log("Merged #"+pr.number+", "+pr.title)
2021-01-24 04:03:18 +07:00
} catch (err) {
console.log(err)
}
2021-01-24 01:48:50 +07:00
}
2021-01-24 00:28:46 +07:00
2021-01-25 00:36:48 +07:00
async function createTranslationPrIfNeeded() {
2021-01-25 00:31:58 +07:00
var translationPulls = await github.pulls.list({...repo,
state : "open" ,
head : context.repo.owner + ":" + translations });
if (translationPulls.data.length == 0) {
var defaultBranch = await getDefaultBranch(context);
await github.pulls.create({...repo,
title : "Translations update" ,
head : translations,
base : defaultBranch });
await github.issues.createComment({...repo,
issue_number : context.issue.number,
body : 'Translations PR created' });
}
}
2021-01-25 00:36:48 +07:00
await createTranslationBranchIfNeeded()
await mergeExistingTranslationsIntoBranch()
await createTranslationPrIfNeeded()
2021-01-22 18:03:26 +07:00