From ea4f36c0a2bd3cf5b0ef9a78e8cb1d2268b0fff7 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Mon, 9 Dec 2024 17:14:17 +0000 Subject: [PATCH 1/2] Update cmd.yml --- .github/workflows/cmd.yml | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index 6cd1adec1d8b..88ae739405e8 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -19,10 +19,10 @@ jobs: steps: - name: Generate token id: generate_token - uses: tibdex/github-app-token@v2.1.0 + uses: actions/create-github-app-token@v1 with: - app_id: ${{ secrets.CMD_BOT_APP_ID }} - private_key: ${{ secrets.CMD_BOT_APP_KEY }} + app-id: ${{ secrets.CMD_BOT_APP_ID }} + private-key: ${{ secrets.CMD_BOT_APP_KEY }} - name: Check if user is a member of the organization id: is-member @@ -392,19 +392,39 @@ jobs: name: command-output path: /tmp/cmd/command_output.log + - name: Generate token + uses: actions/create-github-app-token@v1 + id: generate_token + with: + app-id: ${{ secrets.CMD_BOT_APP_ID }} + private-key: ${{ secrets.CMD_BOT_APP_KEY }} + - name: Commit changes run: | if [ -n "$(git status --porcelain)" ]; then git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" + git config --local user.name "cmd-bot" + + # Push the results to the target branch + git remote add \ + github \ + "https://token:${{ steps.generate_token.outputs.token }}@github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}.git" || : + + push_changes() { + git push github "HEAD:${{ needs.get-pr-branch.outputs.pr-branch }}" + } git add . git restore --staged Cargo.lock # ignore changes in Cargo.lock git commit -m "Update from ${{ github.actor }} running command '${{ steps.get-pr-comment.outputs.group2 }}'" || true - git pull --rebase origin ${{ needs.get-pr-branch.outputs.pr-branch }} - - git push origin ${{ needs.get-pr-branch.outputs.pr-branch }} + # Attempt to push changes + if ! push_changes; then + echo "Push failed, trying to rebase..." + git pull --rebase github "${{ needs.get-pr-branch.outputs.pr-branch }}" + # After successful rebase, try pushing again + push_changes + fi else echo "Nothing to commit"; fi From 4ff552dfc66c3844b51d1f8cfb837e68c1e98bf9 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Mon, 9 Dec 2024 18:18:43 +0000 Subject: [PATCH 2/2] Update cmd.yml --- .github/workflows/cmd.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index 88ae739405e8..b6a50ea0d15e 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -292,9 +292,17 @@ jobs: image: ${{ needs.set-image.outputs.IMAGE }} timeout-minutes: 1440 # 24 hours per runtime steps: + - name: Generate token + uses: actions/create-github-app-token@v1 + id: generate_token + with: + app-id: ${{ secrets.CMD_BOT_APP_ID }} + private-key: ${{ secrets.CMD_BOT_APP_KEY }} + - name: Checkout uses: actions/checkout@v4 with: + token: ${{ steps.generate_token.outputs.token }} repository: ${{ needs.get-pr-branch.outputs.repo }} ref: ${{ needs.get-pr-branch.outputs.pr-branch }} @@ -392,18 +400,12 @@ jobs: name: command-output path: /tmp/cmd/command_output.log - - name: Generate token - uses: actions/create-github-app-token@v1 - id: generate_token - with: - app-id: ${{ secrets.CMD_BOT_APP_ID }} - private-key: ${{ secrets.CMD_BOT_APP_KEY }} - - name: Commit changes run: | if [ -n "$(git status --porcelain)" ]; then - git config --local user.email "action@github.com" - git config --local user.name "cmd-bot" + git config --global user.name command-bot + git config --global user.email "<>" + git config --global pull.rebase false # Push the results to the target branch git remote add \