trigger-property-docs-generation #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Generate Property Docs | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to use for property doc generation" | |
| required: true | |
| type: string | |
| repository_dispatch: | |
| types: [trigger-property-docs-generation] | |
| jobs: | |
| generate-property-docs: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-region: ${{ vars.RP_AWS_CRED_REGION }} | |
| role-to-assume: arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }} | |
| - name: Get secrets from AWS Secrets Manager | |
| uses: aws-actions/aws-secretsmanager-get-secrets@v2 | |
| with: | |
| secret-ids: | | |
| ,sdlc/prod/github/actions_bot_token | |
| parse-json-secrets: true | |
| - name: Checkout the repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ env.ACTIONS_BOT_TOKEN }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Determine tag | |
| id: tag | |
| run: | | |
| if [ -n "${{ github.event.inputs.tag }}" ]; then | |
| echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT | |
| elif [ -n "${{ github.event.client_payload.tag }}" ]; then | |
| echo "tag=${{ github.event.client_payload.tag }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "❌ No tag provided via input or dispatch payload" >&2 | |
| exit 1 | |
| fi | |
| - name: Check if tag is newer than antora.yml latest | |
| id: version_check | |
| run: | | |
| set -euo pipefail | |
| TAG="${{ steps.tag.outputs.tag }}" | |
| CURRENT=$(grep 'latest-redpanda-tag:' antora.yml | awk '{print $2}' | tr -d "\"'") | |
| echo "📄 Current latest-redpanda-tag in antora.yml: $CURRENT" | |
| echo "🔖 Incoming tag: $TAG" | |
| # Strip leading 'v' for numeric comparison | |
| CUR_NUM=$(echo "$CURRENT" | sed 's/^v//') | |
| NEW_NUM=$(echo "$TAG" | sed 's/^v//') | |
| # Compare semver using sort -V | |
| if [ "$(printf "%s\n%s" "$CUR_NUM" "$NEW_NUM" | sort -V | tail -n1)" = "$NEW_NUM" ] && [ "$CUR_NUM" != "$NEW_NUM" ]; then | |
| echo "$TAG is newer than $CURRENT" | |
| echo "is_newer=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "$TAG is not newer than $CURRENT — skipping doc generation" | |
| echo "is_newer=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate property docs | |
| if: steps.version_check.outputs.is_newer == 'true' | |
| run: | | |
| set -euo pipefail | |
| echo "Running doc generation for: ${{ steps.tag.outputs.tag }}" | |
| npx doc-tools generate property-docs \ | |
| --tag "${{ steps.tag.outputs.tag }}" \ | |
| --generate-partials \ | |
| --cloud-support \ | |
| --overrides docs-data/property-overrides.json | |
| env: | |
| GITHUB_TOKEN: ${{ env.ACTIONS_BOT_TOKEN }} | |
| - name: Create pull request | |
| if: steps.version_check.outputs.is_newer == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ env.ACTIONS_BOT_TOKEN }} | |
| commit-message: "auto-docs: Update property docs for ${{ steps.tag.outputs.tag }}" | |
| branch: update-property-docs-${{ steps.tag.outputs.tag }} | |
| title: "auto-docs: Update property docs for tag ${{ steps.tag.outputs.tag }}" | |
| body: | | |
| This PR auto-generates updated Redpanda property documentation for **${{ steps.tag.outputs.tag }}**. | |
| labels: auto-docs | |
| - name: Skip notice | |
| if: steps.version_check.outputs.is_newer != 'true' | |
| run: echo "Skipping doc generation — tag is not newer than latest-redpanda-tag in antora.yml." |