|
| 1 | +name: "Publish Documentation" |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + # Allows manual recovery when the runner's Xcode version path changes. |
| 9 | + xcodeVersion: |
| 10 | + description: 'Xcode version (e.g., 26.0.1 for /Applications/Xcode_26.0.1.app)' |
| 11 | + required: false |
| 12 | + default: '26.0.1' |
| 13 | + type: string |
| 14 | +env: |
| 15 | + # https://github.com/actions/runner-images/blob/main/images/macos/macos-26-arm64-Readme.md |
| 16 | + # Xcode path: `/Applications/Xcode_26.0.1.app` |
| 17 | + XCODE_VERSION: ${{ inputs.xcodeVersion || '26.0.1' }} |
| 18 | +jobs: |
| 19 | + publish-docs: |
| 20 | + runs-on: macos-26 |
| 21 | + if: github.repository != 'plaidev/karte-ios-sdk' |
| 22 | + timeout-minutes: 20 |
| 23 | + permissions: |
| 24 | + contents: read |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 28 | + with: |
| 29 | + submodules: true |
| 30 | + - name: Setup Ruby |
| 31 | + uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0 |
| 32 | + with: |
| 33 | + ruby-version: '3.4' |
| 34 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 35 | + - name: Generate GitHub App token |
| 36 | + uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0 |
| 37 | + id: app-token |
| 38 | + with: |
| 39 | + app-id: ${{ secrets.SHARED_GITHUB_ACTION_AGENT_APP_ID }} |
| 40 | + private-key: ${{ secrets.SHARED_GITHUB_ACTION_AGENT_APP_PRIVATE_KEY }} |
| 41 | + owner: plaidev |
| 42 | + repositories: | |
| 43 | + karte-sdk-docs |
| 44 | + - name: Configure Git |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 47 | + run: | |
| 48 | + git config --global url."https://x-access-token:${GH_TOKEN}@github.com/plaidev/karte-sdk-docs".insteadOf "https://github.com/plaidev/karte-sdk-docs" |
| 49 | + git config --global user.name "github actions" |
| 50 | + git config --global user.email "git@users.noreply.github.com" |
| 51 | + # Jazzy uses xcodebuild to analyze Swift modules, so Xcode must be configured |
| 52 | + - name: Select Xcode version |
| 53 | + run: | |
| 54 | + XCODE_PATH="/Applications/Xcode_${{ env.XCODE_VERSION }}.app" |
| 55 | + echo "Using Xcode version: ${{ env.XCODE_VERSION }}" |
| 56 | + if [ ! -d "${XCODE_PATH}" ]; then |
| 57 | + echo "Error: Xcode not found at ${XCODE_PATH}" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + sudo xcode-select -s "${XCODE_PATH}" |
| 61 | + xcodebuild -version |
| 62 | + - name: Generate documentation |
| 63 | + # Only publish to master when executed on the master branch. |
| 64 | + env: |
| 65 | + BRANCH_REF: ${{ github.ref_name }} |
| 66 | + run: | |
| 67 | + if [ "$BRANCH_REF" = "master" ]; then |
| 68 | + bundle exec ruby ./generate_docs.rb |
| 69 | + else |
| 70 | + BRANCH_NAME="docs-$(date +%Y%m%d-%H%M%S)" |
| 71 | + bundle exec ruby ./generate_docs.rb --branch "$BRANCH_NAME" |
| 72 | + fi |
| 73 | + working-directory: scripts |
| 74 | + - name: Notify Slack on success |
| 75 | + if: success() |
| 76 | + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 |
| 77 | + env: |
| 78 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 79 | + SLACK_MESSAGE: 'Documentation for KARTE iOS SDK was published successfully!' |
| 80 | + SLACK_COLOR: success |
| 81 | + SLACK_ICON_EMOJI: ':apple:' |
| 82 | + - name: Notify Slack on failure |
| 83 | + if: failure() |
| 84 | + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 |
| 85 | + env: |
| 86 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 87 | + SLACK_MESSAGE: 'Failed to publish documentation for KARTE iOS SDK' |
| 88 | + SLACK_COLOR: failure |
| 89 | + SLACK_ICON_EMOJI: ':apple:' |
0 commit comments