kodadot / nft-gallery

Generative Art Marketplace
https://koda.art
MIT License
638 stars 360 forks source link

Automate pushing updates to `beta` branch #5770

Open yangwao opened 1 year ago

yangwao commented 1 year ago

I would like to have regular updates going from main to beta branch with naming which PRs (titles) are being merged there and label it with beta label on weekly basis, Tuesday let's say.

This might be helpful

yangwao commented 1 year ago

ooh

  steps:
    - name: create pull request
      run: gh pr create -B base_branch -H branch_to_merge --title 'Merge branch_to_merge into base_branch' --body 'Created by Github action'
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
yangwao commented 1 year ago

Seems what I want would require bit more scripting..

gh pr create -f -B hyper-mint just list commits

https://github.blog/2021-03-11-scripting-with-github-cli/

yangwao commented 1 year ago
gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  "/repos/kodadot/nft-gallery/pulls"
gh api -X GET '/repos/kodadot/nft-gallery/pulls' -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -f state=closed -f base=main  --jq ".[] | .html_url "
https://github.com/kodadot/nft-gallery/pull/5783
https://github.com/kodadot/nft-gallery/pull/5782
https://github.com/kodadot/nft-gallery/pull/5776
https://github.com/kodadot/nft-gallery/pull/5768
https://github.com/kodadot/nft-gallery/pull/5767
https://github.com/kodadot/nft-gallery/pull/5761
https://github.com/kodadot/nft-gallery/pull/5760
https://github.com/kodadot/nft-gallery/pull/5758
https://github.com/kodadot/nft-gallery/pull/5752
https://github.com/kodadot/nft-gallery/pull/5748
https://github.com/kodadot/nft-gallery/pull/5742
https://github.com/kodadot/nft-gallery/pull/5741
https://github.com/kodadot/nft-gallery/pull/5738
https://github.com/kodadot/nft-gallery/pull/5731
https://github.com/kodadot/nft-gallery/pull/5724
https://github.com/kodadot/nft-gallery/pull/5723
https://github.com/kodadot/nft-gallery/pull/5721
https://github.com/kodadot/nft-gallery/pull/5720
https://github.com/kodadot/nft-gallery/pull/5719
https://github.com/kodadot/nft-gallery/pull/5718
https://github.com/kodadot/nft-gallery/pull/5712
https://github.com/kodadot/nft-gallery/pull/5711
https://github.com/kodadot/nft-gallery/pull/5710
https://github.com/kodadot/nft-gallery/pull/5708
https://github.com/kodadot/nft-gallery/pull/5703
https://github.com/kodadot/nft-gallery/pull/5701
https://github.com/kodadot/nft-gallery/pull/5698
https://github.com/kodadot/nft-gallery/pull/5695
https://github.com/kodadot/nft-gallery/pull/5693
https://github.com/kodadot/nft-gallery/pull/5691
yangwao commented 1 year ago

yet standard input for body file doesn't work for me at gh utility, idk why 👀

gh api -X GET '/repos/kodadot/nft-gallery/pulls' -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -f state=closed -f base=main  --jq ".[] | .html_url " > gh pr create -t "beta update" -H main -B hyper-mint -l beta --body-file -

with file it works

cat ./standardinputfile | gh pr create -t "beta update" -d -H main -B hyper-mint -l beta --body-file -
Warning: 3 uncommitted changes
https://github.com/kodadot/nft-gallery/pull/5785

ook seems this is working


gh api -X GET '/repos/kodadot/nft-gallery/pulls' -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" -f state=closed -f base=main  --jq ".[] | .html_url " > pulls;cat pulls | gh pr create -t "beta update" -d -H main -B hyper-mint -l beta --body-file -

what's needs to be done is to figure out which PRs been already merged in past in beta branch

yangwao commented 1 year ago

seems more elegant and tells if it's merged, not just closed ones

gh pr list -s merged --json url

plus looks like it's possible to search by commit hash

Find a PR that introduced a given commit $ gh pr list --search "" --state merged

yangwao commented 1 year ago

Seems it does working, yet need to add copilot:all or copilot:summary would be nice

gh pr list -s merged --json url -B main --jq ".[] | .url" > pulls; sed 's/^/- /' pulls | gh pr create -t "beta update" -d -H main -B hyper-mint -l beta --body-file -
yangwao commented 1 year ago

Thank you for coming to my classes of bash

gh pr list -s merged --json url -B main --jq ".[] | .url" | sed 's/^/- /' $1 | awk 'BEGIN{print "copilot:summary \n"}{ print}' $1
copilot:summary

- https://github.com/kodadot/nft-gallery/pull/5783
- https://github.com/kodadot/nft-gallery/pull/5776
- https://github.com/kodadot/nft-gallery/pull/5768
- https://github.com/kodadot/nft-gallery/pull/5767
- https://github.com/kodadot/nft-gallery/pull/5761
- https://github.com/kodadot/nft-gallery/pull/5760
- https://github.com/kodadot/nft-gallery/pull/5758
- https://github.com/kodadot/nft-gallery/pull/5752
- https://github.com/kodadot/nft-gallery/pull/5748
- https://github.com/kodadot/nft-gallery/pull/5742
- https://github.com/kodadot/nft-gallery/pull/5741
- https://github.com/kodadot/nft-gallery/pull/5738
- https://github.com/kodadot/nft-gallery/pull/5731
- https://github.com/kodadot/nft-gallery/pull/5724
- https://github.com/kodadot/nft-gallery/pull/5723
- https://github.com/kodadot/nft-gallery/pull/5720
- https://github.com/kodadot/nft-gallery/pull/5719
- https://github.com/kodadot/nft-gallery/pull/5718
- https://github.com/kodadot/nft-gallery/pull/5712
- https://github.com/kodadot/nft-gallery/pull/5711
- https://github.com/kodadot/nft-gallery/pull/5710
- https://github.com/kodadot/nft-gallery/pull/5708
- https://github.com/kodadot/nft-gallery/pull/5703
- https://github.com/kodadot/nft-gallery/pull/5701
- https://github.com/kodadot/nft-gallery/pull/5698
- https://github.com/kodadot/nft-gallery/pull/5695
- https://github.com/kodadot/nft-gallery/pull/5693
- https://github.com/kodadot/nft-gallery/pull/5691
- https://github.com/kodadot/nft-gallery/pull/5685
- https://github.com/kodadot/nft-gallery/pull/5675

only missing piece is to find out which PRs are already merged to target branch

gh pr list -s merged --json url -B main --jq ".[] | .url" | sed 's/^/- /' $1 | awk 'BEGIN{print "copilot:summary \n"}{ print}' $1 | gh pr create -t "beta update" -d -H main -B hyper-mint -l beta --body-file -
yangwao commented 1 year ago

Clue

yangwao commented 1 year ago

Ok from next time I'll try use it apparently, maybe bit limit PRs but doing well

yangwao commented 1 year ago

Yes, I've never committed it and accidentally removed from local stage lol

https://github.com/kodadot/nft-gallery/blob/main/.github/push_release_beta.sh