From 35c24b0380da5c299654a12bffc1d22642148a02 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Mon, 28 Apr 2025 16:40:49 -0300 Subject: [PATCH] Update --- .../auto-merge-staging-into-main.yml | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/.github/workflows/auto-merge-staging-into-main.yml b/.github/workflows/auto-merge-staging-into-main.yml index c04dbaff..963f6d80 100644 --- a/.github/workflows/auto-merge-staging-into-main.yml +++ b/.github/workflows/auto-merge-staging-into-main.yml @@ -33,43 +33,12 @@ jobs: exit 1 fi - - name: Generate GitHub App Installation Token - run: | - echo "${{ secrets.IBCORNELSEN_APP_PRIVATE_KEY }}" > private-key.pem - chmod 600 private-key.pem - - # Generate JWT - now=$(date +%s) - exp=$((now + 600)) # 10 minutes validity - - header_base64=$(echo -n '{"alg":"RS256","typ":"JWT"}' | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - payload_base64=$(echo -n "{\"iat\":$now,\"exp\":$exp,\"iss\":${{ secrets.IBCORNELSEN_APP_ID }}}" | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - header_payload="${header_base64}.${payload_base64}" - - signature=$(echo -n "$header_payload" | openssl dgst -sha256 -sign private-key.pem | openssl base64 -e | tr -d '=' | tr '/+' '_-' | tr -d '\n') - jwt="${header_payload}.${signature}" - - # Request Installation Token - response=$(curl -s -X POST \ - -H "Authorization: Bearer $jwt" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/app/installations/${{ secrets.IBCORNELSEN_INSTALLATION_ID }}/access_tokens) - - installation_token=$(echo "$response" | grep '"token"' | head -n 1 | cut -d '"' -f4) - - # Save the token as a GitHub environment variable - echo "INSTALLATION_TOKEN=$installation_token" >> $GITHUB_ENV - echo $installation_token - - # Clean up private key - rm -f private-key.pem - - name: Create or update PR from staging → main if: steps.check.outcome == 'success' id: cpr uses: peter-evans/create-pull-request@v4 with: - token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: auto-merge staging into main" branch: auto-merge/staging-to-main base: main @@ -83,7 +52,7 @@ jobs: if: steps.cpr.outputs.pull-request-number != '' uses: peter-evans/enable-pull-request-automerge@v3 with: - token: ${{ env.INSTALLATION_TOKEN }} # Use the installation token here + token: ${{ secrets.GITHUB_TOKEN }} pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} merge-method: merge