Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto bump #130

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Sync and Create PRs

on: push
#on:
# release:
# types:
# - released

jobs:
sync_and_create_prs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Get Release Author
id: get_author
run: |
AUTHOR=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/trustwallet/go-primitives/releases/latest" | \
jq -r '.author.login')
echo "The release author is $AUTHOR"
echo "::set-output name=author::$AUTHOR"

- name: Generate Random Branch Name
id: random_branch
run: |
echo "${RANDOM}" >> random-branch.txt
echo "::set-output name=branch_name::$(cat random-branch.txt)"

- name: Create Sync Branch and PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_AUTHOR: ${{ steps.get_author.outputs.author }}
RANDOM_BRANCH: sync/${{ steps.random_branch.outputs.branch_name }}
run: |
# Extract the tag/release version
TAG_NAME=$(echo "${GITHUB_REF}" | sed -n 's/refs\/tags\/\(.*\)/\1/p')

# Set up Git config
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

# Clone and create branches, make changes, and open PRs
REPOS=("trustwallet/backend" "trustwallet/backend-market" "trustwallet/backend-devices" "trustwallet/backend-wallets" "trustwallet/backend-assets")
for repo in "${REPOS[@]}"; do
echo "Processing ${repo}"
git clone "https://github.com/${repo}.git"
cd $(basename ${repo})

# Create a new random branch
git checkout -b "${RANDOM_BRANCH}"
git pull origin main

# Make changes
go get github.com/trustwallet/go-primitives

# Commit and push changes
git commit -am "Sync with go-primitives ${TAG_NAME}"
git push origin "${RANDOM_BRANCH}"

# Create a PR and assign to the release author
PR_TITLE="Sync with go-primitives ${TAG_NAME}"
PR_BODY="Syncing with the new release of go-primitives ${TAG_NAME}"
hub pull-request -b main -h "${RANDOM_BRANCH}" -m "${PR_TITLE}" -m "${PR_BODY}" -a "${RELEASE_AUTHOR}"

cd ..
done