diff --git a/README.md b/README.md index fcd751d..b69672d 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,9 @@ This action offers following inputs that you can use to configure its behavior. 1. **bitrise-workflow** (required) : The name of Bitrise workflow you want to run. +1. **bitrise-pipeline** (optional) : The name of the pipeline you want to + trigger. This is mutually exclusive with `bitrise-workflow` - you must + specify either a workflow or a pipeline, but not both. 1. **listen** (optional) : Stream the logs as the build is happening on Bitrise and wait for build completion. Defaults to `false`, meaning that action will only trigger the build. @@ -192,6 +195,19 @@ To run Bitrise workflow associated with another repo: branch-override: dev ``` +To run Bitrise pipeline: + +```yaml +- name: Run Bitrise pipeline + uses: p-mazhnik/bitrise-run-build@v1 + with: + bitrise-app-slug: bitrise-app-id-2 + bitrise-pipeline: primary + listen: false + bitrise-token: ${{ secrets.BITRISE_TOKEN }} + branch-override: dev +``` + ## Implementation Notes [Bitrise API][bitrise-api] is used to trigger the workflow. diff --git a/action.yml b/action.yml index 5b23492..7e87690 100644 --- a/action.yml +++ b/action.yml @@ -19,12 +19,19 @@ inputs: 'bitrise-token' when 'listen: false'. 'bitrise-token' takes priority." required: false bitrise-workflow: - description: 'The name of the workflow you want to trigger' - required: true + description: + 'The name of the workflow you want to trigger (mutually exclusive with + bitrise-pipeline)' + required: false + bitrise-pipeline: + description: + 'The name of the pipeline you want to trigger (mutually exclusive with + bitrise-workflow)' + required: false listen: description: 'Set to `true` if you want to listen for the build logs and wait for build - completion' + completion. Not supported with bitrise-pipeline' required: false default: 'false' update-interval: diff --git a/src/bitrise/options.ts b/src/bitrise/options.ts index 091d890..c7acf5e 100644 --- a/src/bitrise/options.ts +++ b/src/bitrise/options.ts @@ -14,7 +14,26 @@ import { urlsReferTheSameGitHubRepo } from '../utils' export function createBuildOptions( appDetails: BitriseAppDetails | null ): BitriseBuildOptions { - const workflow = core.getInput('bitrise-workflow', { required: true }) + const workflow = core.getInput('bitrise-workflow', { required: false }) + const pipeline = core.getInput('bitrise-pipeline', { required: false }) + const listen = core.getBooleanInput('listen', { required: false }) + + if (!workflow && !pipeline) { + core.setFailed( + 'Either bitrise-workflow or bitrise-pipeline must be provided' + ) + return {} + } + + if (workflow && pipeline) { + core.setFailed('Cannot specify both bitrise-workflow and bitrise-pipeline') + return {} + } + + if (pipeline && listen) { + core.setFailed('Listen option is not supported with bitrise-pipeline') + return {} + } core.info(`Process "${github.context.eventName}" event`) @@ -74,7 +93,8 @@ export function createBuildOptions( return { ...options, - workflow_id: workflow, + workflow_id: workflow || undefined, + pipeline_id: pipeline || undefined, skip_git_status_report: skipGitStatusReport, environments } diff --git a/src/bitrise/types.ts b/src/bitrise/types.ts index a5b840a..6c9ac2b 100644 --- a/src/bitrise/types.ts +++ b/src/bitrise/types.ts @@ -81,25 +81,33 @@ export interface CommitPathsFilter { } export interface BitriseBuildOptions extends Record { + branch?: string branch_dest?: string branch_dest_repo_owner?: string branch_repo_owner?: string build_request_slug?: string commit_hash?: string commit_message?: string + commit_messages?: string[] + commit_paths?: CommitPathsFilter[] diff_url?: string + environments?: BitriseEnvironment[] + head_repository_url?: string + pipeline_id?: string pull_request_author?: string pull_request_head_branch?: string pull_request_id?: number pull_request_merge_branch?: string - pull_request_repository_url?: string - skip_git_status_report?: boolean - tag?: string pull_request_ready_state?: | 'draft' | 'ready_for_review' | 'converted_to_ready_for_review' - environments?: BitriseEnvironment[] + pull_request_repository_url?: string + pull_request_unverified_merge_branch?: string + base_repository_url?: string + skip_git_status_report?: boolean + tag?: string + workflow_id?: string } export interface BitriseEnvironment {