diff --git a/.github/workflows/rss-monitor.yml b/.github/workflows/rss-monitor.yml new file mode 100644 index 0000000..4816a5f --- /dev/null +++ b/.github/workflows/rss-monitor.yml @@ -0,0 +1,23 @@ +--- +name: Monitor RSS feed + +on: + schedule: + - cron: "0 * * * *" # hourly + +jobs: + rss-monitor: + runs-on: ubuntu-latest + steps: + # TODO: This action outputs a comma separated list of issue numbers + # TODO: Use that to run the follow up action instead of using the separate `rss-notifier.yml` workflow + # TODO: Separate release blog posts and use different labels/discord channel for them + - name: RSS to issues + uses: git-for-windows/rss-to-issues@v0 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + feed: https://lizardbyte.github.io/feed.xml + character-limit: 0 + dry-run: false + max-age: 48h + labels: blog diff --git a/.github/workflows/rss-notifier.yml b/.github/workflows/rss-notifier.yml new file mode 100644 index 0000000..fca0907 --- /dev/null +++ b/.github/workflows/rss-notifier.yml @@ -0,0 +1,146 @@ +--- +name: RSS Notifier + +on: + issues: + types: [opened] + +jobs: + authorize: + runs-on: ubuntu-latest + outputs: + authorized: ${{ steps.authorize.outputs.result }} + steps: + - name: Authorize + id: authorize + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + result-encoding: string + script: | + // get issue + const issue = await github.rest.issues.get({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + + // get author + const author = issue.data.user.login; + + // check if author is LizardByte-bot + if (author === 'LizardByte-bot') { + console.log('Author is LizardByte-bot'); + } else { + console.log('Author is not LizardByte-bot'); + return 'false'; + } + + // check if label is blog + const labels = issue.data.labels.map(label => label.name); + if (labels.includes('blog')) { + console.log('Label is blog'); + } else { + console.log('Label is not blog'); + return 'false'; + } + + return 'true'; + + discord: + if: needs.authorize.outputs.authorized == 'true' + needs: authorize + outputs: + post-url: "https://discord.com/channels/804382334370578482/804383203020374016" + runs-on: ubuntu-latest + steps: + - name: discord + uses: sarisia/actions-status-discord@v1 + with: + avatar_url: ${{ secrets.ORG_LOGO_URL }} + color: 0x00ff00 # green + nodetail: true + nofail: false + title: ${{ github.event.issue.title }} + url: ${{ github.event.issue.body }} + username: ${{ secrets.DISCORD_USERNAME }} + webhook: ${{ secrets.DISCORD_ANNOUNCEMENT_WEBHOOK }} + + facebook: + if: needs.authorize.outputs.authorized == 'true' + needs: authorize + outputs: + post-url: "https://www.facebook.com/LizardByteDev" + runs-on: ubuntu-latest + steps: + - name: facebook-post-action + uses: LizardByte/facebook-post-action@v2024.1207.15428 + with: + page_id: ${{ secrets.FACEBOOK_PAGE_ID }} + access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} + message: ${{ github.event.issue.title }} + url: ${{ github.event.issue.body }} + + reddit: + if: needs.authorize.outputs.authorized == 'true' + needs: authorize + outputs: + post-url: ${{ steps.post.outputs.postUrl }} + runs-on: ubuntu-latest + steps: + - name: reddit + id: post + uses: bluwy/release-for-reddit-action@v2 + with: + username: ${{ secrets.REDDIT_USERNAME }} + password: ${{ secrets.REDDIT_PASSWORD }} + app-id: ${{ secrets.REDDIT_CLIENT_ID }} + app-secret: ${{ secrets.REDDIT_CLIENT_SECRET }} + subreddit: ${{ secrets.REDDIT_SUBREDDIT }} + title: ${{ github.event.issue.title }} + url: ${{ github.event.issue.body }} + flair-id: ${{ secrets.REDDIT_FLAIR_ID }} # https://www.reddit.com/r/>/api/link_flair.json + + x: + if: needs.authorize.outputs.authorized == 'true' + needs: authorize + outputs: + post-url: "https://x.com/LizardByteDev" + runs-on: ubuntu-latest + steps: + - name: x + uses: nearform-actions/github-action-notify-twitter@v1 + # alternative: noweh/post-tweet-v2-action@v1.0 + with: + message: "${{ github.event.issue.title }}: ${{ github.event.issue.body }}" + twitter-app-key: ${{ secrets.X_APP_KEY }} + twitter-app-secret: ${{ secrets.X_APP_SECRET }} + twitter-access-token: ${{ secrets.X_ACCESS_TOKEN }} + twitter-access-token-secret: ${{ secrets.X_ACCESS_TOKEN_SECRET }} + + close-issue: + if: needs.authorize.outputs.authorized == 'true' + needs: + - authorize + - discord + - facebook + - reddit + - x + runs-on: ubuntu-latest + steps: + - name: Close issue + env: + GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + run: | + comment="| Job | Status | Post URL |\n" + comment+="| --- | ------ | -------- |\n" + comment+="| Discord | ${{ needs.discord.result }} | ${{ needs.discord.outputs.post-url }} |\n" + comment+="| Facebook | ${{ needs.facebook.result }} | ${{ needs.facebook.outputs.post-url }} |\n" + comment+="| Reddit | ${{ needs.reddit.result }} | ${{ needs.reddit.outputs.post-url }} |\n" + comment+="| X | ${{ needs.x.result }} | ${{ needs.x.outputs.post-url }} |\n" + + close_reason="completed" + lock_reason="resolved" + + gh issue close ${{ github.event.issue.number }} --comment "${comment}" --reason "${close_reason}" + gh issue lock ${{ github.event.issue.number }} --reason "${lock_reason}"