Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: monitor rss feed from LizardByte website #616

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/rss-monitor.yml
Original file line number Diff line number Diff line change
@@ -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
146 changes: 146 additions & 0 deletions .github/workflows/rss-notifier.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/<subreddit>>/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/[email protected]
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}"
Loading