Skip to content

Commit

Permalink
chore: add base branch for trigger (#481)
Browse files Browse the repository at this point in the history
* chore: add base branch for trigger

* chore: add TRIGGER_WORKFLOW for trigger
  • Loading branch information
JashBook authored Nov 19, 2024
1 parent d0e7757 commit 1f90d84
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/trigger-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
type: string
required: false
default: 'main'
BASE_BRANCH:
description: "The base branch name that triggers the workflow"
type: string
required: false
default: 'main'
WORKFLOW_ID:
description: "The workflow id that triggers the workflow"
type: string
Expand All @@ -33,6 +38,11 @@ on:
type: string
required: false
default: ''
TRIGGER_WORKFLOW:
description: "enable trigger workflow (default: true)"
type: boolean
required: false
default: true
workflow_call:
inputs:
GITHUB_REPO:
Expand All @@ -45,6 +55,11 @@ on:
type: string
required: false
default: 'main'
BASE_BRANCH:
description: "The base branch name that triggers the workflow"
type: string
required: false
default: 'main'
WORKFLOW_ID:
description: "The workflow id that triggers the workflow"
type: string
Expand All @@ -65,6 +80,11 @@ on:
type: string
required: false
default: ''
TRIGGER_WORKFLOW:
description: "enable trigger workflow (default: true)"
type: boolean
required: false
default: true


env:
Expand All @@ -76,12 +96,13 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ inputs.GITHUB_REPO }} Code
- name: Checkout ${{ inputs.GITHUB_REPO }} ${{ inputs.BASE_BRANCH }} Code
uses: actions/checkout@v4
if: ${{ inputs.BRANCH_NAME != '' && inputs.GITHUB_REPO != '' }}
with:
repository: ${{ inputs.GITHUB_REPO }}
token: ${{ env.GITHUB_TOKEN }}
ref: ${{ inputs.BASE_BRANCH }}
fetch-depth: 0

- name: check ${{ inputs.BRANCH_NAME }} exists
Expand Down Expand Up @@ -117,6 +138,7 @@ jobs:
ref: ${{ inputs.APECD_REF }}

- name: trigger-workflow
if: ${{ inputs.TRIGGER_WORKFLOW }}
run: |
cmd="bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 7 --github-token \"${{ env.GITHUB_TOKEN }}\" "
if [[ -n "${{ inputs.GITHUB_REPO }}" ]]; then
Expand Down

0 comments on commit 1f90d84

Please sign in to comment.