1717 steps :
1818 - name : Checkout repository
1919 uses : actions/checkout@v5
20+ with :
21+ fetch-depth : 0 # Fetch all history including tags
22+
23+ - name : Add upstream remote and fetch tags
24+ run : |
25+ git remote add upstream https://github.com/elastic/elastic-agent.git || true
26+ git fetch upstream --tags
27+
28+ - name : Find latest semantic version
29+ id : get_version
30+ run : |
31+ # Get the latest semantic version tag (excluding pre-release versions)
32+ LATEST_VERSION=$(git tag --list | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -1)
33+ echo "Latest version: $LATEST_VERSION"
34+ echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
35+
36+ - name : Pass version to script
37+ run : |
38+ echo "LATEST_VERSION=${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
2039
2140 - name : Set up Python
2241 uses : actions/setup-python@v6
@@ -34,23 +53,49 @@ jobs:
3453 cd docs/scripts/update-docs
3554 python update-components-docs.py
3655
56+ - name : Check if branch already exists
57+ id : check_branch
58+ run : |
59+ BRANCH_NAME="update-docs-${{ steps.get_version.outputs.version }}"
60+ if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
61+ echo "Branch $BRANCH_NAME already exists. Documentation for this version has already been updated."
62+ echo "branch_exists=true" >> $GITHUB_OUTPUT
63+ else
64+ echo "Branch $BRANCH_NAME does not exist. Proceeding with PR creation."
65+ echo "branch_exists=false" >> $GITHUB_OUTPUT
66+ fi
67+
3768 - name : Create Pull Request
69+ if : steps.check_branch.outputs.branch_exists == 'false'
3870 uses : peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
3971 with :
4072 token : ${{ secrets.GITHUB_TOKEN }}
41- commit-message : " docs: update generated documentation"
42- title : " Update generated documentation"
73+ commit-message : " docs: update generated documentation for ${{ steps.get_version.outputs.version }} "
74+ title : " Update generated documentation for ${{ steps.get_version.outputs.version }} "
4375 body : |
44- This PR updates the generated documentation based on the latest local repository data .
76+ This PR updates the generated documentation based on the latest released version **${{ steps.get_version.outputs.version }}** .
4577
78+ ## Changes
4679 - Updates EDOT Collector component tables
4780 - Updates OpenTelemetry Collector Builder (OCB) configuration
48- - Uses local version from version.go file
81+ - Uses data from the latest released version tag: `${{ steps.get_version.outputs.version }}`
82+
83+ ## References
84+ - **Source go.mod**: https://github.com/elastic/elastic-agent/blob/${{ steps.get_version.outputs.version }}/go.mod
85+ - **Source core-components.yaml**: https://github.com/elastic/elastic-agent/blob/${{ steps.get_version.outputs.version }}/internal/pkg/otel/core-components.yaml
86+ - **Release tag**: https://github.com/elastic/elastic-agent/tree/${{ steps.get_version.outputs.version }}
4987
5088 This is an automated PR created by the documentation update workflow.
51- branch : update-docs
89+ branch : update-docs-${{ steps.get_version.outputs.version }}
5290 base : main
5391 delete-branch : true
5492 labels : |
5593 documentation
5694 automated-pr
95+
96+ - name : Skip PR creation (branch exists)
97+ if : steps.check_branch.outputs.branch_exists == 'true'
98+ run : |
99+ echo "✅ Documentation for version ${{ steps.get_version.outputs.version }} has already been updated."
100+ echo "Branch update-docs-${{ steps.get_version.outputs.version }} already exists."
101+ echo "Workflow completed successfully - no action needed."
0 commit comments