From 9abb02e0fc2c0d7182a361710f25bf3bef89b610 Mon Sep 17 00:00:00 2001 From: Maksym H Date: Sun, 19 Jan 2025 18:27:11 +0000 Subject: [PATCH] Update cmd.yml --- .github/workflows/cmd.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cmd.yml b/.github/workflows/cmd.yml index 8ff362f91172a..c7ea428b98f8a 100644 --- a/.github/workflows/cmd.yml +++ b/.github/workflows/cmd.yml @@ -271,12 +271,12 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} script: | let job_url = ${{ steps.build-link.outputs.job_url }} - + let cmd = ${{ needs.get-pr-info.outputs.CMD }} github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `Command "${{ needs.get-pr-info.outputs.CMD }}" has started 🚀 [See logs here](${job_url})` + body: `Command "$cmd" has started 🚀 [See logs here](${job_url})` }) - name: Install dependencies for bench @@ -328,17 +328,20 @@ jobs: name: command-output path: /tmp/cmd/command_output.log - apply-diff-commit: + after-cmd: runs-on: ${{ needs.set-image.outputs.RUNNER }} container: image: ${{ needs.set-image.outputs.IMAGE }} + env: + PR_BRANCH: ${{ needs.get-pr-info.outputs.pr-branch }} + CMD: ${{ needs.get-pr-info.outputs.CMD }} needs: [set-image, get-pr-info, cmd] steps: - name: Checkout uses: actions/checkout@v4 with: repository: ${{ needs.get-pr-info.outputs.repo }} - ref: ${{ needs.get-pr-info.outputs.pr-branch }} + ref: ${{ env.PR_BRANCH }} - name: Download all artifacts uses: actions/download-artifact@v4 @@ -361,8 +364,6 @@ jobs: done git status - - rm -rf patches if [ -n "$(git status --porcelain)" ]; then git config user.name "cmd[bot]" @@ -375,17 +376,17 @@ jobs: "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ needs.get-pr-info.outputs.repo }}.git" || : push_changes() { - git push github "HEAD:${{ needs.get-pr-info.outputs.pr-branch }}" + git push github "HEAD:$PR_BRANCH" } git add . git restore --staged Cargo.lock # ignore changes in Cargo.lock - git commit -m "Update from ${{ github.actor }} running command '${{ needs.get-pr-info.outputs.CMD }}'" || true + git commit -m "Update from ${{ github.actor }} running command '$CMD'" || true # Attempt to push changes if ! push_changes; then echo "Push failed, trying to rebase..." - git pull --rebase github "${{ needs.get-pr-info.outputs.pr-branch }}" + git pull --rebase github $PR_BRANCH # After successful rebase, try pushing again push_changes fi @@ -410,7 +411,7 @@ jobs: --no-color \ --change added changed \ --ignore-errors \ - refs/remotes/origin/master refs/heads/${{ needs.get-pr-info.outputs.pr-branch }}) + refs/remotes/origin/master refs/heads/$PR_BRANCH) # Save the multiline result to the output { @@ -432,6 +433,7 @@ jobs: let runUrl = ${{ needs.cmd.outputs.run_url }} let subweight = process.env.SUBWEIGHT; let cmdOutput = process.env.CMD_OUTPUT; + let cmd = process.env.CMD; console.log(cmdOutput); let subweightCollapsed = subweight.trim() !== '' @@ -446,7 +448,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `Command "${{ needs.get-pr-info.outputs.CMD }}" has finished ✅ [See logs here](${runUrl})${subweightCollapsed}${cmdOutputCollapsed}` + body: `Command "$cmd" has finished ✅ [See logs here](${runUrl})${subweightCollapsed}${cmdOutputCollapsed}` }) - name: Comment PR (Failure) @@ -459,6 +461,7 @@ jobs: script: | let jobUrl = ${{ needs.cmd.outputs.job_url }} let cmdOutput = process.env.CMD_OUTPUT; + let cmd = process.env.CMD; let cmdOutputCollapsed = cmdOutput.trim() !== '' ? `
\n\nCommand output:\n\n${cmdOutput}\n\n
` @@ -468,7 +471,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `Command "${{ needs.get-pr-info.outputs.CMD }}" has failed ❌! [See logs here](${jobUrl})${cmdOutputCollapsed}` + body: `Command "$cmd" has failed ❌! [See logs here](${jobUrl})${cmdOutputCollapsed}` }) - name: Add 😕 reaction on failure @@ -496,3 +499,7 @@ jobs: repo: context.repo.repo, content: '+1' }) + + - name: Clean up + if: ${{ always() }} + run: rm -rf patches