API Documentation Issue Processing #18
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: API Documentation Issue Processing | |
| on: | |
| issues: | |
| types: [opened] # Only trigger on new issues | |
| workflow_dispatch: | |
| inputs: | |
| issue_number: | |
| description: 'Issue number to process (must be a valid positive number)' | |
| required: true | |
| type: number | |
| # Add concurrency to prevent race conditions | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.inputs.issue_number || github.sha }} | |
| cancel-in-progress: true | |
| jobs: | |
| process-issue: | |
| name: Process API Documentation Issue | |
| runs-on: ubuntu-latest | |
| # Only run on the API docs repository and non-internal issues | |
| if: | | |
| github.repository == 'GoHighLevel/highlevel-api-docs' && | |
| (github.event_name == 'workflow_dispatch' || !contains(github.event.issue.labels.*.name, 'internal')) | |
| permissions: | |
| issues: write # Required for issue labeling and commenting | |
| contents: read # Required for checkout | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Check required secrets | |
| run: | | |
| if [ -z "${{ secrets.CLICKUP_API_TOKEN }}" ]; then | |
| echo "CLICKUP_API_TOKEN is not set" | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.ONCALL_AUTH_TOKEN }}" ]; then | |
| echo "ONCALL_AUTH_TOKEN is not set" | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.ONCALL_SERVICE_URL }}" ]; then | |
| echo "ONCALL_SERVICE_URL is not set" | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.ONCALL_API_VERSION }}" ]; then | |
| echo "ONCALL_API_VERSION is not set" | |
| exit 1 | |
| fi | |
| - name: Install axios | |
| run: npm install axios | |
| - name: Process Issue and Create ClickUp Task | |
| id: process | |
| uses: actions/github-script@v7 | |
| env: | |
| CLICKUP_API_TOKEN: ${{ secrets.CLICKUP_API_TOKEN }} | |
| ONCALL_AUTH_TOKEN: ${{ secrets.ONCALL_AUTH_TOKEN }} | |
| ONCALL_SERVICE_URL: ${{ secrets.ONCALL_SERVICE_URL }} | |
| ONCALL_API_VERSION: ${{ secrets.ONCALL_API_VERSION }} | |
| with: | |
| debug: true # Enable debug mode for better error logging | |
| script: | | |
| try { | |
| const processIssue = require('./.github/process-issue.js'); | |
| console.log('Starting issue processing...'); | |
| console.log('Event name:', context.eventName); | |
| console.log('Event payload:', JSON.stringify(context.payload, null, 2)); | |
| console.log('Event issue:', JSON.stringify(context, null, 2)); | |
| console.log(JSON.stringify(github, null, 2)); | |
| if (context.eventName === 'workflow_dispatch') { | |
| // Access issue number from the correct path | |
| const issueNumber = context.payload?.inputs?.issue_number; | |
| console.log('Input issue number:', issueNumber); | |
| if (!issueNumber || Number(issueNumber) <= 0) { | |
| throw new Error('Please provide a valid positive issue number'); | |
| } | |
| } | |
| await processIssue(github, context, core); | |
| } catch (error) { | |
| console.error('Full error details:', error); | |
| core.setFailed(`Error processing issue: ${error.message}`); | |
| throw error; | |
| } |