Skip to content

Commit

Permalink
feat(fern-bot): upgrade notifications are now sent to slack (#1395)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Sep 6, 2024
1 parent 562cd91 commit 59fbc36
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 185 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/deploy-fern-bot-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ env:
GITHUB_APP_WEBHOOK_SECRET: ${{ secrets.FERN_BOT_DEV_GITHUB_APP_WEBHOOK_SECRET }}
DEFAULT_VENUS_ORIGIN: "https://venus-dev2.buildwithfern.com"
DEFAULT_FDR_ORIGIN: "https://registry-dev2.buildwithfern.com"
FERNIE_SLACK_APP_TOKEN: ${{ secrets.FERNIE_SLACK_APP_TOKEN }}
CUSTOMER_ALERTS_SLACK_CHANNEL: "customer-upgrades-dev"
CO_API_KEY: ${{ secrets.DEV_CO_API_KEY }}

jobs:
deploy_dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: 📥 Install
uses: ./.github/actions/install

- name: Compile
run: pnpm compile
run: pnpm compile

- name: 🚀 serverless deploy
env:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/deploy-fern-bot-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
GITHUB_APP_CLIENT_ID: ${{ secrets.FERN_BOT_PROD_GITHUB_APP_CLIENT_ID }}
GITHUB_APP_CLIENT_SECRET: ${{ secrets.FERN_BOT_PROD_GITHUB_APP_CLIENT_SECRET }}
GITHUB_APP_WEBHOOK_SECRET: ${{ secrets.FERN_BOT_PROD_GITHUB_APP_WEBHOOK_SECRET }}
FERNIE_SLACK_APP_TOKEN: ${{ secrets.FERNIE_SLACK_APP_TOKEN }}
CUSTOMER_ALERTS_SLACK_CHANNEL: "customer-upgrades"
DEFAULT_VENUS_ORIGIN: "https://venus.buildwithfern.com"
DEFAULT_FDR_ORIGIN: "https://registry.buildwithfern.com"
CO_API_KEY: ${{ secrets.PROD_CO_API_KEY }}
Expand All @@ -25,13 +27,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: 📥 Install
uses: ./.github/actions/install

- name: Compile
run: pnpm compile
run: pnpm compile

- name: 🚀 serverless deploy
env:
CI: false
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-fern-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ env:
GITHUB_APP_WEBHOOK_SECRET: ${{ secrets.FERN_BOT_DEV_GITHUB_APP_WEBHOOK_SECRET }}
DEFAULT_VENUS_ORIGIN: "https://venus-dev2.buildwithfern.com"
DEFAULT_FDR_ORIGIN: "https://registry-dev2.buildwithfern.com"
FERNIE_SLACK_APP_TOKEN: ${{ secrets.FERNIE_SLACK_APP_TOKEN }}
CUSTOMER_ALERTS_SLACK_CHANNEL: "customer-upgrades-dev"
CO_API_KEY: ${{ secrets.DEV_CO_API_KEY }}

jobs:
Expand Down
6 changes: 5 additions & 1 deletion packages/commons/github/src/createOrUpdatePullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function createOrUpdatePullRequest(
baseRepository: string,
headRepository: string,
branchName: string,
): Promise<void> {
): Promise<string> {
const [headOwner] = headRepository.split("/");
const headBranch = `${headOwner}:${branchName}`;

Expand All @@ -60,6 +60,8 @@ export async function createOrUpdatePullRequest(
created: true,
})}`,
);

return pull.html_url;
} catch (e) {
if (getErrorMessage(e).includes("A pull request already exists for")) {
console.error(`A pull request already exists for ${headBranch}`);
Expand Down Expand Up @@ -96,4 +98,6 @@ export async function createOrUpdatePullRequest(
created: false,
})}`,
);

return pull.html_url;
}
179 changes: 20 additions & 159 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion servers/fern-bot/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ GITHUB_APP_CLIENT_SECRET="FILL ME IN"
GITHUB_APP_WEBHOOK_SECRET="FILL ME IN"
CO_API_KEY="FILL ME IN"
DEFAULT_VENUS_ORIGIN="FILL ME IN"
DEFAULT_FDR_ORIGIN="FILL ME IN"
DEFAULT_FDR_ORIGIN="FILL ME IN"
FERNIE_SLACK_APP_TOKEN="FILL ME IN"
1 change: 1 addition & 0 deletions servers/fern-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@fern-api/venus-api-sdk": "0.8.1-1-gd6d1a5b",
"@fern-fern/generators-sdk": "0.107.0-892e7c392",
"@octokit/openapi-types": "^22.1.0",
"@slack/web-api": "^6.9.0",
"cohere-ai": "^7.9.5",
"execa": "^5.1.1",
"fern-api": "^0.21.0",
Expand Down
3 changes: 3 additions & 0 deletions servers/fern-bot/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ provider:
GITHUB_APP_WEBHOOK_SECRET: ${env:GITHUB_APP_WEBHOOK_SECRET, 'placeholder'}
CO_API_KEY: ${env:CO_API_KEY, 'placeholder'}
DEFAULT_VENUS_ORIGIN: ${env:DEFAULT_VENUS_ORIGIN, 'placeholder'}
DEFAULT_FDR_ORIGIN: ${env:DEFAULT_FDR_ORIGIN, 'placeholder'}
FERNIE_SLACK_APP_TOKEN: ${env:FERNIE_SLACK_APP_TOKEN, 'placeholder'}
CUSTOMER_ALERTS_SLACK_CHANNEL: ${env:CUSTOMER_ALERTS_SLACK_CHANNEL, 'placeholder'}
REPO_TO_RUN_ON: ${env:REPO_TO_RUN_ON, 'OMIT'}
# Roles for the lambda functions
iam:
Expand Down
Loading

0 comments on commit 59fbc36

Please sign in to comment.