Repository navigation
Discussion Labeler #411
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: Discussion Labeler | |
| on: | |
| workflow_dispatch: # Allow manual triggering | |
| discussion: | |
| types: [created] # Trigger only when a new discussion is created | |
| # Use permissions directive to explicitly set token permissions | |
| permissions: | |
| contents: read | |
| discussions: write # Only needed to read/label discussions | |
| jobs: | |
| label-discussions: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4.7.1 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r discussion_labeler/requirements.txt | |
| - name: Run discussion labeler | |
| env: | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| APP_ID: ${{ secrets.APP_ID }} | |
| APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} | |
| APP_INSTALLATION_ID: ${{ secrets.APP_INSTALLATION_ID }} | |
| DEFAULT_REPO: ${{ github.repository }} | |
| REQUEST_TIMEOUT: "30" | |
| RUN_INTERVAL_MINUTES: "300" | |
| SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
| AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }} | |
| AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }} | |
| AZURE_OPENAI_KEY: ${{ secrets.AZURE_OPENAI_KEY }} | |
| run: | | |
| python -c "from discussion_labeler import basic; basic.process_discussions()" | |
| - name: Dispatch to foundry-docs | |
| if: github.event_name == 'discussion' | |
| env: | |
| DISPATCH_TOKEN: ${{ secrets.FOUNDRY_DOCS_DISPATCH_TOKEN }} | |
| DISCUSSION_NUMBER: ${{ github.event.discussion.number }} | |
| DISCUSSION_TITLE: ${{ github.event.discussion.title }} | |
| DISCUSSION_URL: ${{ github.event.discussion.html_url }} | |
| run: | | |
| PAYLOAD=$(jq -n \ | |
| --arg title "$DISCUSSION_TITLE" \ | |
| --arg url "$DISCUSSION_URL" \ | |
| --argjson number "$DISCUSSION_NUMBER" \ | |
| '{event_type: "community-discussion", client_payload: {number: $number, title: $title, url: $url}}') | |
| curl -fsS -X POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer $DISPATCH_TOKEN" \ | |
| https://api.github.com/repos/nicholasdbrady/foundry-docs/dispatches \ | |
| -d "$PAYLOAD" |