Skip to content

Commit

Permalink
Update cmd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Jan 19, 2025
1 parent aef992f commit 9abb02e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -361,8 +364,6 @@ jobs:
done
git status
rm -rf patches
if [ -n "$(git status --porcelain)" ]; then
git config user.name "cmd[bot]"
Expand All @@ -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
Expand All @@ -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
{
Expand All @@ -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() !== ''
Expand All @@ -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)
Expand All @@ -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() !== ''
? `<details>\n\n<summary>Command output:</summary>\n\n${cmdOutput}\n\n</details>`
Expand All @@ -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
Expand Down Expand Up @@ -496,3 +499,7 @@ jobs:
repo: context.repo.repo,
content: '+1'
})
- name: Clean up
if: ${{ always() }}
run: rm -rf patches

0 comments on commit 9abb02e

Please sign in to comment.