Merge docs workflows into single release-triggered pipeline #23
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: Release Docs Check | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| issue_comment: | |
| types: [created] | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Release tag (e.g., 3.12.0)' | |
| required: false | |
| type: string | |
| default: '' | |
| # ============================================ | |
| # PLATFORM CONFIG — Change these for your SDK | |
| # ============================================ | |
| env: | |
| SDK_TYPE: uikit-react-native | |
| PLATFORM: react-native | |
| jobs: | |
| config: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| sdk_type: ${{ steps.set.outputs.sdk_type }} | |
| platform: ${{ steps.set.outputs.platform }} | |
| release_tag: ${{ steps.tag.outputs.release_tag }} | |
| should_run: ${{ steps.tag.outputs.should_run }} | |
| steps: | |
| - id: set | |
| run: | | |
| echo "sdk_type=$SDK_TYPE" >> "$GITHUB_OUTPUT" | |
| echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT" | |
| - id: tag | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| MERGED: ${{ github.event.pull_request.merged }} | |
| INPUT_TAG: ${{ inputs.release_tag }} | |
| run: | | |
| if [ "$EVENT_NAME" = "pull_request" ]; then | |
| if [ "$MERGED" = "true" ] && echo "$HEAD_REF" | grep -q "^release/"; then | |
| TAG=$(echo "$HEAD_REF" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -1 || true) | |
| if [ -n "$TAG" ]; then | |
| echo "release_tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "should_run=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "::warning::Could not extract version from branch '$HEAD_REF'" | |
| echo "should_run=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "should_run=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| elif [ "$EVENT_NAME" = "workflow_dispatch" ]; then | |
| echo "release_tag=$INPUT_TAG" >> "$GITHUB_OUTPUT" | |
| echo "should_run=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| docs-check: | |
| needs: config | |
| if: needs.config.outputs.should_run == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.SDK_REPO_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: 'sendbird', | |
| repo: 'client-workflows', | |
| workflow_id: 'claude-docs-validation.yml', | |
| ref: 'main', | |
| inputs: { | |
| sdk_type: '${{ needs.config.outputs.sdk_type }}', | |
| platform: '${{ needs.config.outputs.platform }}', | |
| release_tag: '${{ needs.config.outputs.release_tag }}', | |
| source_repo: '${{ github.repository }}' | |
| } | |
| }); | |
| pr-info: | |
| if: | | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.html_url, '/pull/') && | |
| contains(github.event.comment.body, '/docs-validation') && | |
| github.event.comment.author_association != 'NONE' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| release_tag: ${{ steps.extract.outputs.release_tag }} | |
| steps: | |
| - name: Extract release tag from PR branch | |
| id: extract | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.issue.number }} | |
| run: | | |
| BRANCH=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json headRefName --jq '.headRefName') | |
| echo "PR branch: $BRANCH" | |
| RELEASE_TAG=$(echo "$BRANCH" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | tail -1 || true) | |
| if [ -z "$RELEASE_TAG" ]; then | |
| echo "::error::PR branch '$BRANCH' does not contain a version number" | |
| exit 1 | |
| fi | |
| echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT" | |
| docs-check-on-comment: | |
| needs: [config, pr-info] | |
| if: | | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.html_url, '/pull/') && | |
| contains(github.event.comment.body, '/docs-validation') && | |
| github.event.comment.author_association != 'NONE' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.SDK_REPO_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: 'sendbird', | |
| repo: 'client-workflows', | |
| workflow_id: 'claude-docs-validation.yml', | |
| ref: 'main', | |
| inputs: { | |
| sdk_type: '${{ needs.config.outputs.sdk_type }}', | |
| platform: '${{ needs.config.outputs.platform }}', | |
| release_tag: '${{ needs.pr-info.outputs.release_tag }}', | |
| source_repo: '${{ github.repository }}' | |
| } | |
| }); |