treetracker-web-map-client icon indicating copy to clipboard operation
treetracker-web-map-client copied to clipboard

Automatically create PR for all prerelease branches.

Open dadiorchen opened this issue 2 years ago • 6 comments
trafficstars

We are working on several different branches, which are listed here: https://github.com/Greenstand/treetracker-web-map-client/blob/168d0cdd537b4af401b57418306b79d783e0a73a/.releaserc.json#L2-L28C1

The goal is that we can automatically create PRs that try to merge main to all these branches, so we can keep the branches synced with the main to avoid problems when we want to release the feature and merge it to main, the pace of the creation of PR could be a week.


Some hints:

  • Please read our readme for more information/guide/tutorial.
  • For design guidelines checkout our Figma design.
  • Here is an engineering book in Greenstand.
  • To know more about our organization, visit our website.
  • If you want to join the slack community (some resources need the community member's permission), please leave your email address.

dadiorchen avatar Jun 04 '23 03:06 dadiorchen

@dadiorchen do you need help? I'd like to work on the CI task like this.

tungbq avatar Jun 04 '23 05:06 tungbq

From my understanding, this task is to automate the process of creating the PRs like this (that need to be run on weekly basis):

  • https://github.com/Greenstand/treetracker-web-map-client/pull/1629
  • https://github.com/Greenstand/treetracker-web-map-client/pull/1622

tungbq avatar Jun 04 '23 05:06 tungbq

@tungbq sorry for the delay, yes, you are right, but because we will create new branch for new feature, so we should read the file: .releaserc.json to get the list of branches that need to merge to

dadiorchen avatar Jun 15 '23 21:06 dadiorchen

I tried to sync the main to cwm, I found some problem:

  1. If we directly use main to merge to cwm in a pull request, then to solve conflict we need to change the main branch, for example: use the conflict page on Github, this is wrong because it bring impacts to the main branch. So I try to create a new branch from main and use that branch to create PR here: https://github.com/Greenstand/treetracker-web-map-client/pull/1644
  2. This PR actually is fine to merge, because the three conflict files: CHANGELOG.md package.json, package-lock.json is useless for cwm, so in the future, when we create the PR, if we can avoid these conflict, it would be a relief for the code reviewer. Here is my command to solve the conflict, by accepting the version of cwm.
git pull --ff greenstand cwm
git checkout --theirs CHANGELOG.md
git checkout --theirs package-lock.json
git add CHANGELOG.md package-lock.json package.json
git commit -m "chore: ignore the change of changelog, package in main"
git push origin main-patch-for-cwm

So seems the ideal steps is:

  1. Create a dedicated branch for the merge, and raise PR against cwm
  2. Ignore the change of main for these three files: CHANGELOG.md package.json package-lock.json

These change is useless for cwm, for example: in the package.json, the conflict is the version number, but apparently we need to keep the version of cwm itself.

dadiorchen avatar Jun 17 '23 06:06 dadiorchen

Correction:

git checkout --theirs package-lock.json

This is wrong and caused problem: https://github.com/Greenstand/treetracker-web-map-client/issues/1646 So I think to avoid this, we'd better regenerate the lock file totally.

dadiorchen avatar Jun 17 '23 08:06 dadiorchen

Here is a manual commands for this operation:

git checkout greenstand/main &&ok
git checkout -b main-patch-for-v2 &&ok
#to checkout the change log from v2 to overwrite the change log in main
git checkout greenstand/v2 -- CHANGELOG.md
#NOTE -n is to skip the pre-commit hook so to avoid unnecessary change on CHANGELOG.md
git add . && git commit -n -m "chore: use changelog from v2 "
#to replace the version
sed -i -E "s/^\s+\"version\": \".*\",/`git show greenstand/v2:package.json | grep -E '^\s+"version": ".+",'`/" packag
&&ok
git add . && git commit -n -m "chore: use version of v2 " &&ok
git push origin main-patch-for-v2 &&ok
gh pr create -B v2 --title="main merge to v2" --body="" &&ok

dadiorchen avatar Jun 19 '23 10:06 dadiorchen