Notifier Discussion #1
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: Notifier Discussion | |
| on: | |
| discussion: | |
| types: [created] | |
| workflow_dispatch: | |
| inputs: | |
| test_category: | |
| description: "테스트할 카테고리" | |
| required: true | |
| type: choice | |
| options: | |
| - General | |
| - Announcement | |
| - Report | |
| test_title: | |
| description: "테스트 게시물 제목" | |
| required: false | |
| default: "테스트 게시물입니다" | |
| permissions: | |
| discussions: read | |
| contents: read | |
| jobs: | |
| notify-discord: | |
| runs-on: ubuntu-latest | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - name: checkout repository | |
| uses: actions/checkout@v4 | |
| - name: send discord notification | |
| uses: actions/github-script@v7 | |
| env: | |
| DISCORD_CHANNEL_ID: ${{ vars.DISCORD_CHANNEL_ID_POST}} | |
| DISCORD_CHANNEL_ID_ANNOUNCEMENT: ${{ vars.DISCORD_CHANNEL_ID_ANNOUNCEMENT }} | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN_NOTIFIER }} | |
| SCRIPT_FULL_PATH: ${{ github.workspace }}/.github/scripts/senders/notifier-discussion.js | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| let discussionData; | |
| if (context.eventName === 'workflow_dispatch') { | |
| discussionData = { | |
| title: '${{ inputs.test_title }}' || '테스트 게시물입니다', | |
| user: { login: context.actor }, | |
| html_url: 'https://github.com/${{ github.repository }}/discussions', | |
| category: { name: '${{ inputs.test_category }}' }, | |
| }; | |
| } else { | |
| discussionData = context.payload.discussion; | |
| } | |
| const { default: notify } = await import(process.env.SCRIPT_FULL_PATH); | |
| await notify({ github, context, core, data: discussionData }); |