-
Notifications
You must be signed in to change notification settings - Fork 2k
135 lines (120 loc) · 4.05 KB
/
check_generated_vrl_docs.yml
File metadata and controls
135 lines (120 loc) · 4.05 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Check Generated VRL Docs Freshness
on:
pull_request:
merge_group:
types: [checks_requested]
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
env:
COMMIT_MESSAGE: "Update generated VRL docs"
COMMIT_AUTHOR: "github-actions[bot]"
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
docs:
- "lib/vector-vrl/**"
- "vdev/**"
- "Cargo.lock"
- ".github/workflows/check_generated_vrl_docs.yml"
run-check-generated-vrl-docs:
needs: changes
if: needs.changes.outputs.docs == 'true'
runs-on: ubuntu-24.04-8core
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: ./.github/actions/setup
with:
vdev: true
mold: false
cargo-cache: false
- name: Regenerate VRL docs
run: make generate-vector-vrl-docs
- name: Check for changes
id: check
run: |
git add docs/generated/
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Check last commit
if: steps.check.outputs.changed == 'true'
id: last-commit
run: |
MSG=$(git log -1 --pretty=%s)
AUTHOR=$(git log -1 --pretty=%an)
if [ "$MSG" = "$COMMIT_MESSAGE" ] && [ "$AUTHOR" = "$COMMIT_AUTHOR" ]; then
echo "is-auto=true" >> "$GITHUB_OUTPUT"
else
echo "is-auto=false" >> "$GITHUB_OUTPUT"
fi
- name: Commit and push
if: >
steps.check.outputs.changed == 'true'
&& steps.last-commit.outputs.is-auto != 'true'
&& github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
id: push
continue-on-error: true
env:
HEAD_REF: ${{ github.head_ref }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "$COMMIT_MESSAGE"
git push origin HEAD:refs/heads/$HEAD_REF
- name: Save PR number for comment workflow
if: >
steps.check.outputs.changed == 'true'
&& steps.last-commit.outputs.is-auto != 'true'
&& github.event_name == 'pull_request'
&& steps.push.outcome != 'success'
run: |
mkdir -p /tmp/docs-check
echo "${{ github.event.pull_request.number }}" > /tmp/docs-check/pr-number
- name: Upload PR metadata
if: >
steps.check.outputs.changed == 'true'
&& steps.last-commit.outputs.is-auto != 'true'
&& github.event_name == 'pull_request'
&& steps.push.outcome != 'success'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: vrl-docs-check-pr
path: /tmp/docs-check/pr-number
- name: Fail if docs are out of date
if: steps.check.outputs.changed == 'true'
run: |
echo "docs/generated/ is out of date. Regenerate with: make generate-vector-vrl-docs"
exit 1
check-generated-vrl-docs:
if: always()
runs-on: ubuntu-latest
needs: run-check-generated-vrl-docs
steps:
- run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "One or more jobs failed or were cancelled"
exit 1
fi