-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci.yml
More file actions
78 lines (70 loc) · 2.35 KB
/
ci.yml
File metadata and controls
78 lines (70 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ==========================================================================
# Vindicta Platform — .specify Repo CI Workflow
# ==========================================================================
# Tailored for a docs/spec repository. Runs pre-commit checks on all PRs
# and pushes to main. Python test jobs auto-skip if no source files exist.
#
# Local testing:
# act pull_request
# ==========================================================================
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: Pre-Commit Checks
runs-on: ubuntu-latest
env:
# no-commit-to-branch is a local-only guard; skip in CI
SKIP: no-commit-to-branch
steps:
- uses: actions/checkout@v4
- name: Check for pre-commit config
id: check-config
run: |
if [ -f .pre-commit-config.yaml ]; then
echo "has_config=true" >> "$GITHUB_OUTPUT"
else
echo "has_config=false" >> "$GITHUB_OUTPUT"
echo "::notice::No .pre-commit-config.yaml found, skipping"
fi
- uses: actions/setup-python@v5
if: steps.check-config.outputs.has_config == 'true'
with:
python-version: '3.12'
- uses: pre-commit/[email protected]
if: steps.check-config.outputs.has_config == 'true'
with:
extra_args: --all-files --show-diff-on-failure
convert-to-draft:
name: Convert to Draft on Failure
runs-on: ubuntu-latest
needs: [pre-commit]
if: failure() && github.event_name == 'pull_request'
continue-on-error: true
permissions:
pull-requests: write
steps:
- name: Convert PR to Draft
uses: actions/github-script@v7
with:
script: |
const mutation = `mutation($id: ID!) {
convertPullRequestToDraft(input: {pullRequestId: $id}) {
pullRequest { isDraft }
}
}`;
try {
await github.graphql(mutation, {
id: context.payload.pull_request.node_id
});
core.notice('PR converted to draft due to CI failure');
} catch (error) {
core.warning(`Could not convert to draft: ${error.message}`);
}