error-db.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: Update Error Database
  2. on:
  3. discussion:
  4. types: [created, edited, category_changed, answered, unanswered]
  5. discussion_comment:
  6. types: [created, edited, deleted]
  7. jobs:
  8. update-error-db:
  9. runs-on: ubuntu-latest
  10. if: github.event.discussion.category.name == 'Errors'
  11. steps:
  12. - name: Query Discussion Data
  13. id: query-data
  14. uses: actions/github-script@v6
  15. with:
  16. script: |
  17. const query = `query ($owner: String!, $name: String!, $discussionNumber: Int!) {
  18. repository(owner: $owner, name: $name) {
  19. discussion(number: $discussionNumber) {
  20. title
  21. bodyHTML
  22. url
  23. answer {
  24. bodyHTML
  25. url
  26. }
  27. comments {
  28. totalCount
  29. }
  30. }
  31. }
  32. }`;
  33. const variables = {
  34. owner: context.repo.owner,
  35. name: context.repo.repo,
  36. discussionNumber: context.payload.discussion.number
  37. }
  38. return await github.graphql(query, variables)
  39. - name: Transform JSON
  40. id: transform-json
  41. run: |
  42. RESULT=$(echo ${JSON_DATA} | jq -c '.repository.discussion | .comments = .comments.totalCount')
  43. echo "::set-output name=result::${RESULT}"
  44. env:
  45. JSON_DATA: ${{ steps.query-data.outputs.result }}
  46. - name: Update Database
  47. run: |
  48. echo TODO
  49. env:
  50. JSON_DATA: ${{ steps.transform-json.outputs.result }}