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

fix: ignore apps with no connectors #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
46 changes: 23 additions & 23 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ on:
schedule:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# Runs every Monday at 00:00
- cron: '0 0 * * 1'
- cron: "0 0 * * 1"
workflow_dispatch:

jobs:
generate:
permissions:
contents: write
pull-requests: write
contents: write
pull-requests: write
runs-on: ubuntu-latest
env:
# the version of deno used by Run on Slack (v1.31.1)
deno-version: v1.31.1 # TODO source this dynamicly from https://api.slack.com/slackcli/metadata.json
# the version of deno used by Run on Slack (v1.46.2)
deno-version: v1.46.2 # TODO source this dynamicly from https://api.slack.com/slackcli/metadata.json

steps:
- name: Setup repo
Expand All @@ -25,41 +25,41 @@ jobs:
uses: denoland/setup-deno@v2
with:
deno-version: ${{ env.deno-version }}

- name: Setup Git config
run: |
git config user.name github-actions
git config user.email ${{ secrets.APPROVED_ACCOUNT }}
git config user.name github-actions
git config user.email ${{ secrets.APPROVED_ACCOUNT }}

- name: Set BRANCH_NAME
# example: BRANCH_NAME=generate_2023-07-18_18-09
run: echo "BRANCH_NAME=generate_$(date +"%Y-%m-%d_%H-%M")" >> $GITHUB_ENV

- name: Run generation script
run: ./scripts/generate

- name: Commit changes
id: commit
continue-on-error: true
run: |
git checkout -b $BRANCH_NAME
[[ $(git ls-files --other --modified --exclude-standard) == "src/connectors/mod.ts" ]] && { echo "No real changes. Do not commit."; exit 1; }
git add --all
git commit -m "Automated commit: Latest generated changes from schedule action"
git checkout -b $BRANCH_NAME
[[ $(git ls-files --other --modified --exclude-standard) == "src/connectors/mod.ts" ]] && { echo "No real changes. Do not commit."; exit 1; }
git add --all
git commit -m "Automated commit: Latest generated changes from schedule action"

- name: Create Pull Request
if: ${{ steps.commit.outcome == 'success' }}
run: |
git push --set-upstream origin $BRANCH_NAME
gh pr create --label "enhancement" --title "Latest generated changes" --body \
"## 🚀 Automated Pull Request: Coded-Connectors Update
This PR brings the latest changes to coded-connectors, fueled by Slack's latest data. Developers can now access the newest features effortlessly.
git push --set-upstream origin $BRANCH_NAME
gh pr create --label "enhancement" --title "Latest generated changes" --body \
"## 🚀 Automated Pull Request: Coded-Connectors Update
This PR brings the latest changes to coded-connectors, fueled by Slack's latest data. Developers can now access the newest features effortlessly.

GitHub prevents [triggering a workflow from a workflow](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow), the **checks** on this pull request will not be triggered automatically :sweat_smile:
To trigger the **checks** on this pull request:
1. close the pull request
2. reopen the pull request
GitHub prevents [triggering a workflow from a workflow](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow), the **checks** on this pull request will not be triggered automatically :sweat_smile:
To trigger the **checks** on this pull request:
1. close the pull request
2. reopen the pull request

*Github-Actions* 🤖"
*Github-Actions* 🤖"
env:
GH_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
16 changes: 15 additions & 1 deletion scripts/src/templates/mod_tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ const renderFunctions = (
return `{${typescript.join(",\n")}}`;
};

const getCleanNamespaces = (
certifiedApps: CertifiedApp[],
): string[] => {
return certifiedApps.reduce<string[]>(
(unsortedNamespaces, app) => {
if (app.functions.length > 0) {
unsortedNamespaces.push(app.namespace);
}
return unsortedNamespaces;
},
[],
).sort();
};

export const ConnectorModTemplate = (
namespace: string,
functionRecords: FunctionRecord[],
Expand Down Expand Up @@ -64,7 +78,7 @@ export const ConnectorModTemplate = (
export const ConnectorsModTemplate = (
certifiedApps: CertifiedApp[],
) => {
const namespaces = certifiedApps.map((app) => app.namespace).sort();
const namespaces = getCleanNamespaces(certifiedApps);

const typescript: string[] = [];
typescript.push(autogeneratedComment(true));
Expand Down
4 changes: 4 additions & 0 deletions scripts/src/write_typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ try {
}`,
);

if (certifiedApp.functions.length == 0) {
continue;
}

const validFunctions = await certifiedApp.functions.reduce<
Promise<FunctionRecord[]>
>(
Expand Down