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 :
2023-03-06 20:24:07 +07:00
- uses : actions/checkout@v3
2022-03-09 20:03:40 +07:00
- uses : actions/setup-node@v2
- name : Generate new buildConfig.kt and changelog.md files
run : |
npm i @octokit/rest
node .github/workflows/incrementVersionAndChangelog.js
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
node .github/workflows/mergeTranslations.js ${{ 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
uses : "actions/github-script@v5"
with :
github-token : ${{ secrets.ACTIONS_ACCESS_TOKEN }}
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
2023-11-28 17:06:42 +07:00
# Even though the PR was "merged", the head is still not updated - takes Github a while longer
# Since there's no simple way to poll for this, we just wait
2023-11-28 17:14:56 +07:00
# - uses: GuillaumeFalourd/wait-sleep-action@v1
# with:
# time: '60' # In seconds
2023-11-28 17:06:42 +07:00
2023-11-28 16:06:40 +07:00
- uses : actions/checkout@v3
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
2023-11-28 16:06:40 +07:00
- uses : actions/setup-node@v2
- name : Increment version and release
run : |
2023-11-28 16:52:19 +07:00
export version=$(node .github/workflows/releasePatch.js)
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 :
2023-03-06 20:24:07 +07:00
- uses : actions/checkout@v3
2022-03-09 20:03:40 +07:00
- uses : actions/setup-node@v2
- 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