Skip to content

Commit 68e30c3

Browse files
author
dmitrivasilyev
committed
add launchpad publish rule
1 parent c1529f4 commit 68e30c3

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

.github/workflows/bench.yml

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Benchmarks
33
permissions:
44
contents: write
55
packages: read
6+
pull-requests: write
67

78
on:
89
workflow_dispatch:
@@ -51,6 +52,22 @@ jobs:
5152
- name: Checkout repository
5253
uses: actions/checkout@v4
5354

55+
- name: Verify required tools
56+
run: |
57+
echo "Checking required tools for PR creation..."
58+
if ! command -v git &> /dev/null; then
59+
echo "❌ git is not installed"
60+
exit 1
61+
fi
62+
echo "✓ git: $(git --version)"
63+
64+
if ! command -v gh &> /dev/null; then
65+
echo "❌ gh (GitHub CLI) is not installed"
66+
exit 1
67+
fi
68+
echo "✓ gh: $(gh --version | head -1)"
69+
echo "All required tools are available"
70+
5471
- name: Log in to Container Registry
5572
uses: docker/login-action@v3
5673
with:
@@ -83,16 +100,37 @@ jobs:
83100
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-image.outputs.image-tag }} \
84101
cargo test --release --test bdd -- --tags @bench
85102
86-
- name: Commit benchmark results
103+
- name: Create Pull Request with benchmark results
104+
env:
105+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87106
run: |
88107
git config --local user.email "github-actions[bot]@users.noreply.github.com"
89108
git config --local user.name "github-actions[bot]"
90-
# Save benchmarks.md before reset
91-
cp documentation/docs/benchmarks.md /tmp/benchmarks.md.tmp
109+
110+
# Create a unique branch name with timestamp
111+
BRANCH_NAME="benchmark-results-$(date +%Y%m%d-%H%M%S)"
112+
113+
# Fetch latest and create new branch from target
92114
git fetch origin ${{ github.ref_name }}
93-
git reset --hard origin/${{ github.ref_name }}
94-
# Restore benchmarks.md after reset
95-
cp /tmp/benchmarks.md.tmp documentation/docs/benchmarks.md
115+
git checkout -b "$BRANCH_NAME" origin/${{ github.ref_name }}
116+
117+
# Copy the updated benchmarks.md from the previous HEAD (where tests ran)
118+
git checkout @{-1} -- documentation/docs/benchmarks.md
119+
120+
# Check if there are any changes to commit
96121
git add documentation/docs/benchmarks.md
97-
git diff --staged --quiet || git commit -m "Update benchmark results [skip ci]"
98-
git push --force-with-lease
122+
if git diff --staged --quiet; then
123+
echo "No changes to benchmark results, skipping PR creation"
124+
exit 0
125+
fi
126+
127+
# Commit and push
128+
git commit -m "Update benchmark results [skip ci]"
129+
git push origin "$BRANCH_NAME"
130+
131+
# Create Pull Request
132+
gh pr create \
133+
--title "Update benchmark results" \
134+
--body "Automated benchmark results update from CI workflow. This PR updates the benchmark comparison table in documentation/docs/benchmarks.md." \
135+
--base "${{ github.ref_name }}" \
136+
--head "$BRANCH_NAME"

0 commit comments

Comments
 (0)