From d6931f15ac6da8c7964f555d8d344274fb8e96ae Mon Sep 17 00:00:00 2001 From: Denis <136321897+defisaur@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:24:18 +0400 Subject: [PATCH 1/4] fix --- .github/workflows/release.yml | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4c3d7a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Sync and Create PRs + +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-branch-${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 --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + # 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 (example: go get go-primitives) + 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 From 47ffd21cfd64bbee842ca6c37fca3d2facc34515 Mon Sep 17 00:00:00 2001 From: Denis <136321897+defisaur@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:41:34 +0400 Subject: [PATCH 2/4] fix --- .github/workflows/release.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c3d7a4..7fce40c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,10 @@ name: Sync and Create PRs -on: - release: - types: - - released +on: push +#on: +# release: +# types: +# - released jobs: sync_and_create_prs: From ad82dbe0118d482b00c12874b753da0bff91cb68 Mon Sep 17 00:00:00 2001 From: Denis <136321897+defisaur@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:45:49 +0400 Subject: [PATCH 3/4] fix --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7fce40c..ee027fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: - name: Generate Random Branch Name id: random_branch run: | - echo "random-branch-${RANDOM}" >> random-branch.txt + echo "${RANDOM}" >> random-branch.txt echo "::set-output name=branch_name::$(cat random-branch.txt)" - name: Create Sync Branch and PRs @@ -39,8 +39,8 @@ jobs: TAG_NAME=$(echo "${GITHUB_REF}" | sed -n 's/refs\/tags\/\(.*\)/\1/p') # Set up Git config - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" + git config --local user.email "action@github.com" + 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") From 53ce8ebe26233ccbfb5c1a32d52a292efc73b1cd Mon Sep 17 00:00:00 2001 From: Denis <136321897+defisaur@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:38:43 +0400 Subject: [PATCH 4/4] fix --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee027fd..c032ec6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,7 +53,7 @@ jobs: git checkout -b "${RANDOM_BRANCH}" git pull origin main - # Make changes (example: go get go-primitives) + # Make changes go get github.com/trustwallet/go-primitives # Commit and push changes