action.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: AI Release Notes
  2. description: Generate AI release notes using git and openai, outputs 'RELEASE_NOTES' and 'OPENAI_PROMPT'
  3. inputs:
  4. OPENAI_API_KEY:
  5. required: true
  6. type: string
  7. GHA_PAT:
  8. required: true
  9. type: string
  10. model_name:
  11. required: false
  12. type: string
  13. default: gpt-4o-mini
  14. repo_path:
  15. required: false
  16. type: string
  17. custom_prompt:
  18. required: false
  19. default: ''
  20. type: string
  21. git_ref:
  22. required: true
  23. type: string
  24. head_ref:
  25. required: true
  26. type: string
  27. base_ref:
  28. required: true
  29. type: string
  30. outputs:
  31. RELEASE_NOTES:
  32. description: "AI generated release notes"
  33. value: ${{ steps.ai_release_notes.outputs.RELEASE_NOTES }}
  34. OPENAI_PROMPT:
  35. description: "Prompt used to generate release notes"
  36. value: ${{ steps.ai_prompt.outputs.OPENAI_PROMPT }}
  37. env:
  38. GITHUB_REF: ${{ inputs.git_ref }}
  39. BASE_REF: ${{ inputs.base_ref }}
  40. HEAD_REF: ${{ inputs.head_ref }}
  41. runs:
  42. using: "composite"
  43. steps:
  44. - uses: actions/checkout@v4
  45. with:
  46. repository: ${{ inputs.repo_path }}
  47. token: ${{ inputs.GHA_PAT }}
  48. ref: ${{ env.GITHUB_REF }}
  49. fetch-depth: 0
  50. - name: Set Workspace
  51. shell: bash
  52. run: |
  53. pip install tiktoken
  54. pip install pytz
  55. # Github outputs: 'OPENAI_PROMPT'
  56. - name: Add Git Info to base prompt
  57. id: ai_prompt
  58. shell: bash
  59. env:
  60. BASE_REF: ${{ env.BASE_REF }}
  61. HEAD_SHA: ${{ env.HEAD_SHA }}
  62. PR_TITLE: ${{ github.event.pull_request.title }}
  63. PR_BODY: ${{ github.event.pull_request.body }}
  64. MODEL_NAME: ${{ inputs.model_name }}
  65. CUSTOM_PROMPT: ${{ inputs.custom_prompt }} # Default: ''
  66. run: python .github/scripts/release-notes-prompt.py
  67. # Github outputs: 'RELEASE_NOTES'
  68. - name: Generate AI release notes
  69. id: ai_release_notes
  70. shell: bash
  71. env:
  72. OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }}
  73. CUSTOM_PROMPT: ${{ steps.ai_prompt.outputs.OPENAI_PROMPT }}
  74. MODEL_NAME: ${{ inputs.model_name }}
  75. run: python .github/scripts/ai-release-notes.py