|
| 1 | +--- |
| 2 | +name: RSS Notifier |
| 3 | + |
| 4 | +on: |
| 5 | + issues: |
| 6 | + types: [opened] |
| 7 | + |
| 8 | +jobs: |
| 9 | + authorize: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + authorized: ${{ steps.authorize.outputs.result }} |
| 13 | + steps: |
| 14 | + - name: Authorize |
| 15 | + id: authorize |
| 16 | + uses: actions/github-script@v7 |
| 17 | + with: |
| 18 | + github-token: ${{ secrets.GH_BOT_TOKEN }} |
| 19 | + result-encoding: string |
| 20 | + script: | |
| 21 | + // get issue |
| 22 | + const issue = await github.rest.issues.get({ |
| 23 | + owner: context.repo.owner, |
| 24 | + repo: context.repo.repo, |
| 25 | + issue_number: context.issue.number |
| 26 | + }); |
| 27 | +
|
| 28 | + // get author |
| 29 | + const author = issue.data.user.login; |
| 30 | +
|
| 31 | + // check if author is LizardByte-bot |
| 32 | + if (author === 'LizardByte-bot') { |
| 33 | + console.log('Author is LizardByte-bot'); |
| 34 | + } else { |
| 35 | + console.log('Author is not LizardByte-bot'); |
| 36 | + return 'false'; |
| 37 | + } |
| 38 | +
|
| 39 | + // check if label is blog |
| 40 | + const labels = issue.data.labels.map(label => label.name); |
| 41 | + if (labels.includes('blog')) { |
| 42 | + console.log('Label is blog'); |
| 43 | + } else { |
| 44 | + console.log('Label is not blog'); |
| 45 | + return 'false'; |
| 46 | + } |
| 47 | +
|
| 48 | + return 'true'; |
| 49 | +
|
| 50 | + discord: |
| 51 | + if: needs.authorize.outputs.authorized == 'true' |
| 52 | + needs: authorize |
| 53 | + outputs: |
| 54 | + post-url: "https://discord.com/channels/804382334370578482/804383203020374016" |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: discord |
| 58 | + uses: sarisia/actions-status-discord@v1 |
| 59 | + with: |
| 60 | + avatar_url: ${{ secrets.ORG_LOGO_URL }} |
| 61 | + color: 0x00ff00 |
| 62 | + nodetail: true |
| 63 | + nofail: false |
| 64 | + title: ${{ github.event.issue.title }} |
| 65 | + url: ${{ github.event.issue.body }} |
| 66 | + username: ${{ secrets.DISCORD_USERNAME }} |
| 67 | + webhook: ${{ secrets.DISCORD_ANNOUNCEMENT_WEBHOOK }} |
| 68 | + |
| 69 | + fb_group: |
| 70 | + if: false && needs.authorize.outputs.authorized == 'true' |
| 71 | + needs: authorize |
| 72 | + outputs: |
| 73 | + post-url: "https://www.facebook.com/groups/lizardbyte" |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: facebook-post-action |
| 77 | + uses: ReenigneArcher/facebook-post-action@v1 |
| 78 | + with: |
| 79 | + page_id: ${{ secrets.FACEBOOK_GROUP_ID }} |
| 80 | + access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} |
| 81 | + message: ${{ github.event.issue.title }} |
| 82 | + url: ${{ github.event.issue.body }} |
| 83 | + |
| 84 | + fb_page: |
| 85 | + if: needs.authorize.outputs.authorized == 'true' |
| 86 | + needs: authorize |
| 87 | + outputs: |
| 88 | + post-url: "https://www.facebook.com/LizardByteDev" |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + - name: facebook-post-action |
| 92 | + uses: ReenigneArcher/facebook-post-action@v1 |
| 93 | + with: |
| 94 | + page_id: ${{ secrets.FACEBOOK_PAGE_ID }} |
| 95 | + access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} |
| 96 | + message: ${{ github.event.issue.title }} |
| 97 | + url: ${{ github.event.issue.body }} |
| 98 | + |
| 99 | + reddit: |
| 100 | + if: needs.authorize.outputs.authorized == 'true' |
| 101 | + needs: authorize |
| 102 | + outputs: |
| 103 | + post-url: ${{ steps.post.outputs.postUrl }} |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - name: reddit |
| 107 | + id: post |
| 108 | + uses: bluwy/release-for-reddit-action@v2 |
| 109 | + with: |
| 110 | + username: ${{ secrets.REDDIT_USERNAME }} |
| 111 | + password: ${{ secrets.REDDIT_PASSWORD }} |
| 112 | + app-id: ${{ secrets.REDDIT_CLIENT_ID }} |
| 113 | + app-secret: ${{ secrets.REDDIT_CLIENT_SECRET }} |
| 114 | + subreddit: ${{ secrets.REDDIT_SUBREDDIT }} |
| 115 | + title: ${{ github.event.issue.title }} |
| 116 | + url: ${{ github.event.issue.body }} |
| 117 | + flair-id: ${{ secrets.REDDIT_FLAIR_ID }} # https://www.reddit.com/r/<subreddit>>/api/link_flair.json |
| 118 | + |
| 119 | + x: |
| 120 | + if: needs.authorize.outputs.authorized == 'true' |
| 121 | + needs: authorize |
| 122 | + outputs: |
| 123 | + post-url: "https://x.com/LizardByteDev" |
| 124 | + runs-on: ubuntu-latest |
| 125 | + steps: |
| 126 | + - name: x |
| 127 | + uses: nearform-actions/github-action-notify-twitter@v1 |
| 128 | + # alternative: noweh/[email protected] |
| 129 | + with: |
| 130 | + message: "${{ github.event.issue.title }}: ${{ github.event.issue.body }}" |
| 131 | + twitter-app-key: ${{ secrets.X_APP_KEY }} |
| 132 | + twitter-app-secret: ${{ secrets.X_APP_SECRET }} |
| 133 | + twitter-access-token: ${{ secrets.X_ACCESS_TOKEN }} |
| 134 | + twitter-access-token-secret: ${{ secrets.X_ACCESS_TOKEN_SECRET }} |
| 135 | + |
| 136 | + close-issue: |
| 137 | + if: always() |
| 138 | + needs: |
| 139 | + - authorize |
| 140 | + - discord |
| 141 | + - facebook_group |
| 142 | + - facebook_page |
| 143 | + - reddit |
| 144 | + - x |
| 145 | + runs-on: ubuntu-latest |
| 146 | + steps: |
| 147 | + - name: Close issue |
| 148 | + env: |
| 149 | + GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }} |
| 150 | + run: | |
| 151 | + comment="| Job | Status | Post URL |\n" |
| 152 | + comment+="| --- | ------ | -------- |\n" |
| 153 | + comment+="| Authorize | ${{ needs.authorize.result }} | |\n" |
| 154 | + comment+="| Discord | ${{ needs.discord.result }} | ${{ needs.discord.outputs.post-url }} |\n" |
| 155 | + # comment+="| Facebook Group | ${{ needs.fb_group.result }} | ${{ needs.fb_group.outputs.post-url }} |\n" |
| 156 | + comment+="| Facebook Page | ${{ needs.fb_page.result }} | ${{ needs.fb_page.outputs.post-url }} |\n" |
| 157 | + comment+="| Reddit | ${{ needs.reddit.result }} | ${{ needs.reddit.outputs.post-url }} |\n" |
| 158 | + comment+="| X | ${{ needs.x.result }} | ${{ needs.x.outputs.post-url }} |\n" |
| 159 | +
|
| 160 | + close_reason="completed" |
| 161 | + lock_reason="resolved" |
| 162 | +
|
| 163 | + gh issue close ${{ github.event.issue.number }} --comment "${comment}" --reason "${close_reason}" |
| 164 | + gh issue lock ${{ github.event.issue.number }} --reason "${lock_reason}" |
0 commit comments