# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Invite a usergroup to channel on: issues: types: - labeled jobs: run: name: Respond to reports of a new problem runs-on: ubuntu-latest if: ${{ github.event.label.name == 'bug' }} steps: - name: Create a new Slack channel for communications id: conversation uses: slackapi/slack-github-action@v4.0.0 with: errors: true method: conversations.create # https://docs.slack.dev/reference/methods/conversations.create/ token: ${{ secrets.SLACK_BOT_TOKEN }} payload: | name: issue-${{ github.event.issue.number }} - name: Send the issue link into the Slack channel uses: slackapi/slack-github-action@v4.0.0 with: errors: true method: chat.postMessage # https://docs.slack.dev/reference/methods/chat.postMessage/ token: ${{ secrets.SLACK_BOT_TOKEN }} payload: | channel: ${{ steps.conversation.outputs.channel_id }} text: "An issue was opened : ${{ github.event.issue.html_url }}" - name: Gather information of those to add id: members uses: slackapi/slack-github-action@v4.0.0 with: errors: true method: usergroups.users.list # https://docs.slack.dev/reference/methods/usergroups.users.list/ token: ${{ secrets.SLACK_BOT_TOKEN }} payload: | usergroup: ${{ secrets.SLACK_USERGROUP_ID }} - name: Combine the list of usergroup users run: | SLACK_USERGROUP_USER_IDS=$(echo '${{ steps.members.outputs.response }}' | jq -r '.users | join(",")' ) echo "SLACK_USERGROUP_USER_IDS=$SLACK_USERGROUP_USER_IDS" >> $GITHUB_ENV - name: Add the usergroup to the channel uses: slackapi/slack-github-action@v4.0.0 with: errors: true method: conversations.invite # https://docs.slack.dev/reference/methods/conversations.invite/ token: ${{ secrets.SLACK_BOT_TOKEN }} payload: | channel: ${{ steps.conversation.outputs.channel_id }} users: ${{ env.SLACK_USERGROUP_USER_IDS }}