Skip to content

Commit 7414f4b

Browse files
authored
GH: Add action to build 9.x series plugin docs (#1829)
1 parent 3002cba commit 7414f4b

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: "Plugin docgen for specified 9.0 and later"
2+
3+
run-name: "Plugin docgen for ${{ github.event.inputs.branch }}"
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: 'Branch to update plugin docs'
10+
required: true
11+
default: '9.0'
12+
type: string
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
jobs:
19+
build:
20+
name: "Update docs for ${{ github.event.inputs.branch }}"
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: jruby
26+
- uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
27+
with:
28+
distribution: 'temurin'
29+
java-version: '17'
30+
- name: Clone elastic/docs-tools
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
32+
with:
33+
repository: elastic/docs-tools
34+
path: docs-tools
35+
fetch-depth: 1
36+
- name: Clone elastic/logstash-docs
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
38+
with:
39+
repository: elastic/logstash-docs
40+
path: logstash-docs
41+
fetch-depth: 1
42+
ref: ${{ github.event.inputs.branch }}
43+
- name: Clone elastic/docs
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
45+
with:
46+
repository: elastic/docs
47+
path: docs
48+
fetch-depth: 1
49+
- name: Generate plugin versions
50+
working-directory: ./logstash
51+
env:
52+
GRADLE_OPTS: "-Dorg.gradle.jvmargs=\"-Xmx4g\""
53+
run: ./gradlew generatePluginsVersion
54+
- name: Generate plugin docs
55+
working-directory: ./docs-tools
56+
run: |
57+
bundle install --path=vendor/bundle
58+
bundle exec ruby plugindocs.rb --skip-existing --output-path ../logstash-docs ../logstash/plugins_version_docs.json
59+
- name: Build docs
60+
working-directory: ./logstash-docs
61+
run: ../docs/build_docs --asciidoctor --respect_edit_url_overrides --doc docs/plugins/index.asciidoc --chunk 1
62+
- run: echo "T=$(date +%s)" >> $GITHUB_ENV
63+
- run: echo "BRANCH=update_docs_${T}" >> $GITHUB_ENV
64+
- name: Commit and Push
65+
working-directory: ./logstash-docs
66+
run: |
67+
git config user.email 43502315+logstashmachine@users.noreply.github.com
68+
git config user.name logstashmachine
69+
git checkout -b $BRANCH
70+
git add .
71+
git status
72+
if [[ -z $(git status --porcelain) ]]; then echo "No changes. We're done."; exit 0; fi
73+
git commit -m "updated docs for ${{ github.event.inputs.branch }}" -a
74+
git push origin $BRANCH
75+
- name: Create Pull Request
76+
run: |
77+
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d "{\"title\": \"updated docs for ${{ github.event.inputs.branch }}\",\"head\": \"${BRANCH}\",\"base\": \"${{ github.event.inputs.branch }}\"}" https://api.github.com/repos/elastic/logstash-docs/pulls
78+
- run: echo "### Updated docs for ${{ github.event.inputs.branch }} :rocket:" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)