Create GitHub Discussions #18
This file contains 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: Create GitHub Discussions | |
on: | |
pull_request: | |
types: [opened] | |
paths: | |
- 'src/content/apps/**' | |
workflow_dispatch: | |
inputs: | |
createForExisting: | |
description: 'Create discussions for existing apps' | |
required: true | |
default: 'true' | |
type: boolean | |
jobs: | |
create-discussion: | |
runs-on: ubuntu-latest | |
permissions: | |
discussions: write | |
pull-requests: read | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get App Data from PR | |
if: github.event_name == 'pull_request' | |
id: app-data-pr | |
run: | | |
# Add script to extract app data from PR changes | |
echo "name=..." >> $GITHUB_OUTPUT | |
echo "author=..." >> $GITHUB_OUTPUT | |
echo "description=..." >> $GITHUB_OUTPUT | |
- name: Create Discussion for PR | |
if: github.event_name == 'pull_request' | |
uses: abirismyname/[email protected] | |
with: | |
title: "Vote: ${{ steps.app-data-pr.outputs.name }} by ${{ steps.app-data-pr.outputs.author }}" | |
body: | | |
🗳️ **Vote for this app by giving it a 👍 reaction!** | |
${{ steps.app-data-pr.outputs.description }} | |
repository-id: ${{ secrets.REPO_ID }} | |
category-id: ${{ secrets.CAT_ID }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Existing Apps Data | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.createForExisting == 'true' | |
id: app-data-existing | |
run: | | |
# Add script to get existing apps data | |
echo "apps<<EOF" >> $GITHUB_OUTPUT | |
# Output JSON array of apps with name, author, description | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create Discussions for Existing Apps | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.createForExisting == 'true' | |
uses: abirismyname/[email protected] | |
with: | |
title: "Vote: ${{ fromJson(steps.app-data-existing.outputs.apps).name }} by ${{ fromJson(steps.app-data-existing.outputs.apps).author }}" | |
body: | | |
🗳️ **Vote for this app by giving it a 👍 reaction!** | |
${{ fromJson(steps.app-data-existing.outputs.apps).description }} | |
repository-id: ${{ secrets.REPO_ID }} | |
category-id: ${{ secrets.CAT_ID }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |