Skip to content

Commit

Permalink
feat: add pipeline support (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafpato authored Jan 27, 2025
1 parent fbdc3ec commit 0d3bbbb
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 9 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 10 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 22 additions & 2 deletions src/bitrise/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down Expand Up @@ -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
}
Expand Down
16 changes: 12 additions & 4 deletions src/bitrise/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,33 @@ export interface CommitPathsFilter {
}

export interface BitriseBuildOptions extends Record<string, any> {
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 {
Expand Down

0 comments on commit 0d3bbbb

Please sign in to comment.