Skip to content

Commit

Permalink
chore: add social integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Jul 19, 2023
1 parent 1f42a5a commit 4a8b746
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Discord
on:
release:
types: [published]

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Notes 📝
id: notes
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
result-encoding: string
script: |
notes = context.payload.release.body
// replace all non-supported characters
notes = notes.replaceAll('###', '')
notes = notes.trim()
return notes
- name: Changelog 📝
uses: sebastianpopp/discord-action@4f2d5417bc61a79593304a62e71cd32427c17790
with:
webhook: ${{ secrets.CHANGELOG_WEBHOOK }}
message: |
📦 ${{ github.event.release.name }}
${{steps.notes.outputs.result}}
${{ github.event.release.html_url }}
26 changes: 26 additions & 0 deletions .github/workflows/social.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Social
on:
release:
types: [published]
workflow_dispatch:

jobs:
bluesky:
runs-on: ubuntu-latest
steps:
- name: Install Node ⬇️
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
with:
node-version: 18
- name: Checkout code 👋
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Skyt 🌤️
working-directory: scripts/bluesky
env:
BLUESKY_IDENTIFIER: ${{ secrets.BLUESKY_IDENTIFIER }}
BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }}
OWNER: JanDeDobbeleer
REPO: oh-my-posh
run: |
npm install
node main.js
44 changes: 44 additions & 0 deletions scripts/bluesky/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { BskyAgent } = require('@atproto/api');
const {Octokit} = require("@octokit/rest");

(async function main () {
const github = new Octokit();
const response = await github.rest.repos.getLatestRelease({
owner: process.env.OWNER,
repo: process.env.REPO,
});
const release = response.data;

let notes = release.body;

// replace all non-supported characters
notes = notes.replaceAll('### ', '');
notes = notes.replaceAll('**', '');
notes = notes.replace(/ \(\[[0-9a-z]+\]\(.*\)/g, '');
notes = notes.trim();

const agent = new BskyAgent({ service: 'https://bsky.social' });
await agent.login({ identifier: process.env.BLUESKY_IDENTIFIER, password: process.env.BLUESKY_PASSWORD });

const version = release.name;

const text = `📦 ${version}
${notes}
#aliae #oss #cli #opensource`;

console.log(`Posting to Bluesky:\n\n${text}`);

await agent.post({
text: text,
embed: {
$type: 'app.bsky.embed.external',
external: {
uri: `https://github.com/JanDeDobbeleer/aliae/releases/tag/${version}`,
title: "Something is sprouting 🌱",
description: version,
},
},
});
})();

0 comments on commit 4a8b746

Please sign in to comment.