-
Notifications
You must be signed in to change notification settings - Fork 237
Add build trigger filters #3058
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7eb64d
Add build trigger filters
HarshMN2345 282ec7b
fix: migrate project API calls to org-scoped Organization SDK
HarshMN2345 d6c3d78
format
HarshMN2345 eed9ee2
fix: replace helper text with tooltip info icon on build trigger filters
HarshMN2345 80f4e87
fix: parallelize org project lookups in auth preview route
HarshMN2345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...ject-[region]-[project]/functions/function-[function]/settings/updateBuildTriggers.svelte
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| <script lang="ts"> | ||
| import { invalidate } from '$app/navigation'; | ||
| import { page } from '$app/state'; | ||
| import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; | ||
| import { CardGrid } from '$lib/components'; | ||
| import { Dependencies } from '$lib/constants'; | ||
| import { Button, Form, InputTags } from '$lib/elements/forms'; | ||
| import { symmetricDifference } from '$lib/helpers/array'; | ||
| import { addNotification } from '$lib/stores/notifications'; | ||
| import { sdk } from '$lib/stores/sdk'; | ||
| import { type Models, Runtime, type Scopes } from '@appwrite.io/console'; | ||
| import { Icon, Layout, Tooltip } from '@appwrite.io/pink-svelte'; | ||
| import { IconInfo } from '@appwrite.io/pink-icons-svelte'; | ||
|
|
||
| export let func: Models.Function; | ||
|
|
||
| type FuncWithTriggers = Models.Function & { | ||
| providerBranches?: string[]; | ||
| providerPaths?: string[]; | ||
| }; | ||
|
|
||
| function normalizeTriggerPatterns(patterns: string[] = []) { | ||
| return [...new Set(patterns.map((pattern) => pattern.trim()).filter(Boolean))]; | ||
| } | ||
|
|
||
| let providerBranches: string[] = normalizeTriggerPatterns( | ||
| (func as FuncWithTriggers).providerBranches | ||
| ); | ||
| let providerPaths: string[] = normalizeTriggerPatterns( | ||
| (func as FuncWithTriggers).providerPaths | ||
| ); | ||
| let savedBranches = normalizeTriggerPatterns((func as FuncWithTriggers).providerBranches); | ||
| let savedPaths = normalizeTriggerPatterns((func as FuncWithTriggers).providerPaths); | ||
|
|
||
| async function update() { | ||
| providerBranches = normalizeTriggerPatterns(providerBranches); | ||
| providerPaths = normalizeTriggerPatterns(providerPaths); | ||
|
|
||
| try { | ||
| await sdk.forProject(page.params.region, page.params.project).functions.update({ | ||
| functionId: func.$id, | ||
| name: func.name, | ||
| runtime: func.runtime as Runtime, | ||
| execute: func.execute?.length ? (func.execute as string[]) : undefined, | ||
| events: func.events?.length ? (func.events as string[]) : undefined, | ||
| schedule: func.schedule ?? undefined, | ||
| timeout: func.timeout ?? undefined, | ||
| enabled: func.enabled ?? undefined, | ||
| logging: func.logging ?? undefined, | ||
| entrypoint: func.entrypoint ?? undefined, | ||
| commands: func.commands ?? undefined, | ||
| scopes: func.scopes?.length ? (func.scopes as Scopes[]) : undefined, | ||
| installationId: func.installationId ?? undefined, | ||
| providerRepositoryId: func.providerRepositoryId ?? undefined, | ||
| providerBranch: func.providerBranch ?? undefined, | ||
| providerSilentMode: func.providerSilentMode ?? undefined, | ||
| providerRootDirectory: func.providerRootDirectory ?? undefined, | ||
| buildSpecification: func.buildSpecification ?? undefined, | ||
| providerBranches, | ||
| providerPaths | ||
| }); | ||
| savedBranches = [...providerBranches]; | ||
| savedPaths = [...providerPaths]; | ||
| await invalidate(Dependencies.FUNCTION); | ||
| addNotification({ | ||
| type: 'success', | ||
| message: 'Build triggers have been updated successfully' | ||
| }); | ||
| trackEvent(Submit.FunctionUpdateConfiguration); | ||
| } catch (error) { | ||
| addNotification({ | ||
| type: 'error', | ||
| message: error.message | ||
| }); | ||
| trackError(error, Submit.FunctionUpdateConfiguration); | ||
| } | ||
| } | ||
|
|
||
| $: isDisabled = | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| !symmetricDifference(providerBranches, savedBranches).length && | ||
| !symmetricDifference(providerPaths, savedPaths).length; | ||
| </script> | ||
|
|
||
| {#if func.providerRepositoryId} | ||
| <Form onSubmit={update}> | ||
| <CardGrid> | ||
| <svelte:fragment slot="title">Build triggers</svelte:fragment> | ||
| Control which branch pushes and file changes trigger automatic deployments. Use glob patterns | ||
| to include or exclude specific branches and paths. | ||
| <svelte:fragment slot="aside"> | ||
| <Layout.Stack gap="xl"> | ||
| <Layout.Stack gap="s"> | ||
| <InputTags | ||
| id="providerBranches" | ||
| label="Branch filters" | ||
| placeholder={providerBranches.length | ||
| ? '' | ||
| : 'e.g. main, feat/*, !hotfix/*'} | ||
| bind:tags={providerBranches}> | ||
| <Tooltip slot="info"> | ||
| <Icon icon={IconInfo} size="s" /> | ||
| <span slot="tooltip" | ||
| >Leave empty to deploy on all branches. Prefix with ! to | ||
| exclude.</span> | ||
| </Tooltip> | ||
| </InputTags> | ||
| </Layout.Stack> | ||
| <Layout.Stack gap="s"> | ||
| <InputTags | ||
| id="providerPaths" | ||
| label="Path filters" | ||
| placeholder={providerPaths.length ? '' : 'e.g. src/**, !docs/**'} | ||
| bind:tags={providerPaths}> | ||
| <Tooltip slot="info"> | ||
| <Icon icon={IconInfo} size="s" /> | ||
| <span slot="tooltip" | ||
| >Leave empty to deploy on all file changes. Prefix with ! to | ||
| exclude.</span> | ||
| </Tooltip> | ||
| </InputTags> | ||
| </Layout.Stack> | ||
| </Layout.Stack> | ||
| </svelte:fragment> | ||
| <svelte:fragment slot="actions"> | ||
| <Button disabled={isDisabled} submit>Update</Button> | ||
| </svelte:fragment> | ||
| </CardGrid> | ||
| </Form> | ||
| {/if} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.