From f78ef75cef02c5cba354f43c084d7f9ef9f851b6 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:51:11 +0100 Subject: [PATCH 1/7] add workflow --- .github/workflow/push_pr.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflow/push_pr.yml diff --git a/.github/workflow/push_pr.yml b/.github/workflow/push_pr.yml new file mode 100644 index 0000000..aa2e273 --- /dev/null +++ b/.github/workflow/push_pr.yml @@ -0,0 +1,52 @@ +on: + release: + types: [ created ] + +name: on-creating-new-tag + +jobs: + send-pull-requests: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Get production version from tag + id: get_version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Checkout to other repo + uses: actions/checkout@v3 + with: + repository: curvefi/curve-js + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Send pull-request to curve-js + run: | + TAG=${{ env.RELEASE_VERSION }} + ORG="curvefi" + CURRENT_REPOSITORY="$ORG/deposit-and-stake-zap" + REPOSITORY="$ORG/curve-js" + FOLDER="bin/$REPOSITORY" + BRANCH_NAME="deployment-$CURRENT_REPOSITORY-$TAG" + + # Setup the committers identity. + git config user.email "Curve@users.noreply.github.com" + git config user.name "Curvefi" + + # Create a new feature branch for the changes. + git checkout -b $BRANCH_NAME + + # Store the PAT in a file that can be accessed by the GitHub CLI. + echo "${{ secrets.ACCESS_TOKEN }}" > token.txt + + # Create an empty commit for PR + git commit --allow-empty -m "deployment from $CURRENT_REPOSITORY - $TAG" + git push -u origin $BRANCH_NAME + + # Authorize GitHub CLI for the current repository and + # create a pull-requests containing the updates. + gh auth login --with-token < token.txt + gh pr create \ + --body "Link to release: https://github.com/$CURRENT_REPOSITORY/releases/tag/$TAG" \ + --title "Deployment from $CURRENT_REPOSITORY - $TAG" \ + --head "$BRANCH_NAME" \ + --base "master" From 83fbdfa82dab94b60b3df90f9cbfd1c6f6650022 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:18:24 +0100 Subject: [PATCH 2/7] initialize action --- .github/workflow/push_pr.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflow/push_pr.yml b/.github/workflow/push_pr.yml index aa2e273..a32d784 100644 --- a/.github/workflow/push_pr.yml +++ b/.github/workflow/push_pr.yml @@ -1,4 +1,8 @@ on: + push: + branches: + - main + - master release: types: [ created ] From e9bff7909a73cb5b85e238551af4cafda8281b0b Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:22:00 +0100 Subject: [PATCH 3/7] fix naming --- .github/{workflow => workflows}/push_pr.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/push_pr.yml (100%) diff --git a/.github/workflow/push_pr.yml b/.github/workflows/push_pr.yml similarity index 100% rename from .github/workflow/push_pr.yml rename to .github/workflows/push_pr.yml From 491c444d48394ce9ce56ef03d2e21e54c85cc622 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:22:43 +0100 Subject: [PATCH 4/7] remove push --- .github/workflows/push_pr.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index a32d784..aa2e273 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -1,8 +1,4 @@ on: - push: - branches: - - main - - master release: types: [ created ] From 0ab741988d0b80632c6e5bee3178490f8f766b25 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:30:08 +0100 Subject: [PATCH 5/7] fix user email --- .github/workflows/push_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index aa2e273..13abd99 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -29,7 +29,7 @@ jobs: BRANCH_NAME="deployment-$CURRENT_REPOSITORY-$TAG" # Setup the committers identity. - git config user.email "Curve@users.noreply.github.com" + git config user.email "Curvefi@users.noreply.github.com" git config user.name "Curvefi" # Create a new feature branch for the changes. From b4a38cc57982e214501498942f71d3a459fb7a27 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:20:53 +0100 Subject: [PATCH 6/7] add saving release file --- .github/workflows/push_pr.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index 13abd99..040e36c 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -13,6 +13,28 @@ jobs: id: get_version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Checkout to repo + uses: actions/checkout@v3 + with: + token: ${{ secrets.ACCESS_TOKEN }} + + - name: Create release file + run: | + TITLE="${{ github.event.release.name }}" + NOTES="${{ github.event.release.body }}" + DATE=$(date '+%d-%m-%Y') + mkdir deployments + echo $NOTES >> "deployments/release-$TITLE-$DATE.txt" + + git config user.email "curvefi@users.noreply.github.com" + git config user.name "curvefi" + git remote update + git fetch + git checkout master + git add deployments + git commit -m "chore: add release file - $TITLE" + git push + - name: Checkout to other repo uses: actions/checkout@v3 with: From f90457d07b65ad0965ec6a8504a9230962f60301 Mon Sep 17 00:00:00 2001 From: Oleg <40476427+amfet42@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:22:31 +0100 Subject: [PATCH 7/7] fix creating directory --- .github/workflows/push_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_pr.yml b/.github/workflows/push_pr.yml index 040e36c..511b558 100644 --- a/.github/workflows/push_pr.yml +++ b/.github/workflows/push_pr.yml @@ -23,7 +23,7 @@ jobs: TITLE="${{ github.event.release.name }}" NOTES="${{ github.event.release.body }}" DATE=$(date '+%d-%m-%Y') - mkdir deployments + mkdir -p deployments echo $NOTES >> "deployments/release-$TITLE-$DATE.txt" git config user.email "curvefi@users.noreply.github.com"