Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/fancy-planets-cut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@embedly/builder": minor
"@embedly/bot": minor
---

switched out rehype/unified for cheerio. added posthog for a/b testing. added embed link style test
12 changes: 12 additions & 0 deletions .changeset/pink-owls-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@embedly/platforms": patch
"@embedly/builder": patch
"@embedly/logging": patch
"@embedly/config": patch
"@embedly/parser": patch
"@embedly/types": patch
"@embedly/api": patch
"@embedly/bot": patch
---

feat(ci): split github actions across multiple files
58 changes: 58 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bug Report
description: Report a bug with Embedly
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug.

- type: textarea
id: what-happened
attributes:
label: What happened?
description: Describe what went wrong
placeholder: The bot didn't embed my Twitter link
validations:
required: true

- type: textarea
id: expected
attributes:
label: What did you expect to happen?
description: What should have happened instead?
placeholder: Expected a rich embed with the tweet content
validations:
required: true

- type: input
id: link
attributes:
label: Link to the post
description: If applicable, include the link that failed
placeholder: https://twitter.com/user/status/123456789
validations:
required: false

- type: dropdown
id: platform
attributes:
label: Platform
description: Which platform is this bug related to?
options:
- Twitter/X
- Instagram
- TikTok
- Threads
- Other
validations:
required: true

- type: textarea
id: additional
attributes:
label: Additional context
description: Any other info that might be relevant
placeholder: This only happens with reply chains
validations:
required: false
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Questions
url: https://github.com/embed-team/embedly/discussions
about: For general questions, use Discussions instead
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Feature Request
description: Suggest a new feature for Embedly
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Got an idea? Let's hear it.

- type: textarea
id: feature
attributes:
label: What feature do you want?
description: Describe the feature you'd like to see
placeholder: Add support for Bluesky posts
validations:
required: true

- type: textarea
id: why
attributes:
label: Why?
description: Why would this be useful?
placeholder: Bluesky is growing and Discord embeds don't work for it
validations:
required: true

- type: textarea
id: alternative
attributes:
label: Alternatives
description: Are there any workarounds or alternative solutions?
placeholder: Currently have to manually screenshot posts
validations:
required: false
51 changes: 8 additions & 43 deletions .github/workflows/ci.yml → .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,48 @@
name: CI
name: Changesets

env:
PNPM_VERSION: "10.15.1"
NODE_VERSION: "24"

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint and format check
run: pnpm biome ci
- name: Build all packages
run: pnpm build
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Get Release Version
id: versioning
run: |
if pnpm changeset status --output release.json; then
echo "VERSION=$(jq -r '.releases.[0].newVersion' release.json)" >> $GITHUB_OUTPUT
rm release.json
fi

- name: Create Release Pull Request or Publish
id: changesets
- name: Create Release Pull Request
uses: changesets/action@v1
with:
publish: pnpm changeset publish
title: '🔖 chore(release): v${{ steps.versioning.outputs.VERSION }}'
commit: '🔖 chore(release): v${{ steps.versioning.outputs.VERSION }}'
title: '🔖 chore(release): v${{ steps.versioning.outputs.VERSION }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/tag-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Tag Release

on:
pull_request:
types: [closed]
branches: [main]

jobs:
tag:
if: |
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.title, '🔖 chore(release):')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main

- name: Get version from package.json
id: version
run: |
VERSION=$(jq -r '.version' apps/bot/package.json)
echo "VERSION=v$VERSION" >> $GITHUB_OUTPUT
echo "Creating tag: v$VERSION"

- name: Check if tag exists
id: check_tag
run: |
if git rev-parse "${{ steps.version.outputs.VERSION }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Create and push tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a ${{ steps.version.outputs.VERSION }} -m "Release ${{ steps.version.outputs.VERSION }}"
git push origin ${{ steps.version.outputs.VERSION }}

- name: Tag already exists
if: steps.check_tag.outputs.exists == 'true'
run: echo "Tag ${{ steps.version.outputs.VERSION }} already exists, skipping"
41 changes: 41 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Validate (Lint and Build)
env:
PNPM_VERSION: "10.15.1"
NODE_VERSION: "24"

on:
push:
branches: ['**']
pull_request:
branches: [main, devel]

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint and format check
run: pnpm biome ci
- name: Build all packages
run: pnpm build
3 changes: 2 additions & 1 deletion apps/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@logtail/node": "^0.5.6",
"@sapphire/discord.js-utilities": "^7.3.3",
"@sapphire/framework": "^5.4.0",
"discord.js": "~14.25.1"
"discord.js": "~14.25.1",
"posthog-node": "^5.20.0"
}
}
10 changes: 8 additions & 2 deletions apps/bot/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {
GatewayIntentBits,
PresenceUpdateStatus
} from "discord.js";
import { PostHog } from "posthog-node";

declare module "@sapphire/framework" {
interface Container {
betterstack: Logtail;
embed_authors: Map<string, string>;
posthog: PostHog;
}
}

Expand Down Expand Up @@ -43,11 +45,15 @@ export class EmbedlyClient extends SapphireClient {
}
);
container.embed_authors = new Map();
container.posthog = new PostHog(process.env.POSTHOG_API_KEY!, {
host: process.env.POSTHOG_HOST
});
return super.login(token);
}

public override destroy() {
container.betterstack?.flush();
public override async destroy() {
await container.betterstack?.flush();
await container.posthog.shutdown();
return super.destroy();
}
}
21 changes: 15 additions & 6 deletions apps/bot/src/commands/embed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { treaty } from "@elysiajs/eden";
import type { App } from "@embedly/api";
import { Embed, EmbedFlags } from "@embedly/builder";
import {
Embed,
EmbedFlagNames,
type EmbedFlags
} from "@embedly/builder";
import {
EMBEDLY_EMBED_CREATED_COMMAND,
EMBEDLY_NO_LINK_IN_MESSAGE,
Expand Down Expand Up @@ -99,7 +103,7 @@ export class EmbedCommand extends Command {
| Command.ChatInputCommandInteraction
| Command.ContextMenuCommandInteraction,
content: string,
flags?: Partial<Record<EmbedFlags, boolean>>
flags?: Partial<EmbedFlags>
) {
const log_ctx = {
interaction_id: interaction.id,
Expand Down Expand Up @@ -190,13 +194,18 @@ export class EmbedCommand extends Command {
interaction: Command.ChatInputCommandInteraction
) {
const url = interaction.options.getString("url", true);
const link_style = (await this.container.posthog.getFeatureFlag(
"embed-link-styling-test",
interaction.user.id
)) as EmbedFlags[EmbedFlagNames.LinkStyle] | undefined;
this.fetchEmbed(interaction, url, {
[EmbedFlags.MediaOnly]:
[EmbedFlagNames.MediaOnly]:
interaction.options.getBoolean("media_only") ?? false,
[EmbedFlags.SourceOnly]:
[EmbedFlagNames.SourceOnly]:
interaction.options.getBoolean("source_only") ?? false,
[EmbedFlags.Spoiler]:
interaction.options.getBoolean("spoiler") ?? false
[EmbedFlagNames.Spoiler]:
interaction.options.getBoolean("spoiler") ?? false,
[EmbedFlagNames.LinkStyle]: link_style ?? "control"
});
}
}
Loading