Compare commits
2 Commits
terminate-
...
feat-auto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc21036448 | ||
|
|
4fd75701c7 |
45
.woodpecker/server-clippy-fix.yaml
Normal file
45
.woodpecker/server-clippy-fix.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
when:
|
||||
- event: push
|
||||
branch: main
|
||||
path:
|
||||
include: ['.woodpecker/server-*.yaml', 'server/**']
|
||||
|
||||
steps:
|
||||
- name: clippy-fix
|
||||
image: jdxcode/mise:latest
|
||||
directory: server
|
||||
environment:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_TARGET_DIR: /usr/local/cargo/target
|
||||
CARGO_HOME: /usr/local/cargo/registry
|
||||
GITEA_TOKEN:
|
||||
from_secret: GITEA_TOKEN
|
||||
GITEA_URL:
|
||||
from_secret: GITEA_URL
|
||||
volumes:
|
||||
- cargo-target:/usr/local/cargo/target
|
||||
- cargo-registry:/usr/local/cargo/registry
|
||||
commands:
|
||||
- apt-get update && apt-get install -y pkg-config curl
|
||||
- mise install rust
|
||||
- mise install protoc
|
||||
- mise exec rust -- cargo clippy --fix --allow-dirty --all
|
||||
- |
|
||||
cd ..
|
||||
if git diff --quiet HEAD; then
|
||||
echo "No machine-applicable clippy fixes found, nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
git config user.email "bot@arbiter"
|
||||
git config user.name "Clippy Bot"
|
||||
git add -A
|
||||
git commit -m "fix(clippy): apply auto-fixable linting suggestions"
|
||||
git config http.extraHeader "Authorization: token ${GITEA_TOKEN}"
|
||||
git push --force origin HEAD:refs/heads/bot/clippy-fixes
|
||||
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST "${GITEA_URL}/api/v1/repos/${CI_REPO}/pulls" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"title\":\"fix(clippy): apply auto-fixable linting suggestions\",\"head\":\"bot/clippy-fixes\",\"base\":\"main\",\"body\":\"Automated clippy fixes generated by CI bot.\"}")
|
||||
echo "Gitea API response: ${HTTP_STATUS}"
|
||||
[ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "409" ] || [ "$HTTP_STATUS" = "422" ] || exit 1
|
||||
Reference in New Issue
Block a user