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 :
2022-03-09 20:03:40 +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)
# 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
runs-on : ubuntu-latest
steps :
2024-06-19 21:53:58 +07:00
- uses : actions/checkout@v4
2024-08-14 14:40:00 +07:00
- uses : actions/setup-node@v4
2022-03-09 20:03:40 +07:00
- name : Generate new buildConfig.kt and changelog.md files
run : |
npm i @octokit/rest
2024-06-23 03:51:14 +07:00
node .github/workflows/incrementVersionAndChangelog.mjs
2023-06-04 03:04:24 +07:00
2022-03-09 20:03:40 +07:00
rm -rf node_modules # Now we need to remove extraneous node.js parts before commit
rm package-lock.json
rm package.json
2023-06-04 03:04:24 +07:00
2022-03-09 20:03:40 +07:00
- name : Create new branch with changes
2023-06-04 03:04:24 +07:00
uses : EndBug/add-and-commit@v9 # You can change this to use a specific version.
2022-03-09 20:03:40 +07:00
with :
new_branch : version_rollout
2022-03-14 16:47:04 +07:00
message : 'Bump version and create initial changelog entry'
2022-03-09 20:03:40 +07:00
- name : Add translation PRs to the new branch, and PR the new branch to master
2023-06-04 03:04:24 +07:00
run : |
2022-03-09 20:03:40 +07:00
npm i @octokit/rest
2024-06-23 03:51:14 +07:00
node .github/workflows/mergeTranslations.mjs ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} version_rollout
2023-06-04 03:04:24 +07:00
2023-11-28 16:06:40 +07:00
release_patch_version :
if : github.event_name == 'issue_comment' && (github.event.comment.body == 'release patch') && 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
runs-on : ubuntu-latest
steps :
2023-11-28 16:59:07 +07:00
- name : Merge Pull Request
2024-08-14 14:40:00 +07:00
uses : actions/github-script@v5
2023-11-28 16:59:07 +07:00
with :
2023-11-28 17:20:12 +07:00
github-token : ${{ secrets.ACTIONS_ACCESS_TOKEN }} # Required because default workflow token can't merge PRs
2023-11-28 16:59:07 +07:00
script : |
const repository = context.repo
await github.rest.pulls.merge({
merge_method : "squash" ,
owner : repository.owner,
pull_number : ${{ github.event.issue.number }},
repo : repository.repo,
})
2023-11-28 16:06:40 +07:00
2024-06-19 21:53:58 +07:00
- uses : actions/checkout@v4
2023-11-28 16:57:40 +07:00
with : # Required for triggering the deploy on tags added by this automation
# See https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs
token : ${{ secrets.ACTIONS_ACCESS_TOKEN }}
2023-11-28 17:14:56 +07:00
ref : master # By default will checkout *the version at time of trigger* which does *not* contain the PR we just merged!
2023-11-28 16:57:40 +07:00
2024-08-14 14:40:00 +07:00
- uses : actions/setup-node@v4
2023-11-28 16:06:40 +07:00
- name : Increment version and release
run : |
2024-06-23 03:51:14 +07:00
export version=$(node .github/workflows/releasePatch.mjs)
2023-11-28 16:20:58 +07:00
echo "VERSION=$version" >> "$GITHUB_ENV"
2023-11-28 16:06:40 +07:00
2023-11-28 16:20:58 +07:00
- uses : stefanzweifel/git-auto-commit-action@v5
with :
commit_message : ${{env.VERSION}}
tagging_message : ${{env.VERSION}}
2022-03-09 20:03:40 +07:00
merge_translations :
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
runs-on : ubuntu-latest
steps :
2024-06-19 21:53:58 +07:00
- uses : actions/checkout@v4
2024-08-14 14:40:00 +07:00
- uses : actions/setup-node@v4
2022-03-09 20:03:40 +07:00
- name : Add translation PRs to the new branch, and PR the new branch to master
# 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.
2023-06-04 03:04:24 +07:00
run : |
2022-03-09 20:03:40 +07:00
npm i @octokit/rest
node .github/workflows/mergeTranslations.js ${{ secrets.ACTIONS_ACCESS_TOKEN }} ${{ github.event.issue.number }} translations