From 2616fdbcfacd45c4935ed08c5ccc54e658434941 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 24 Oct 2024 17:20:49 +0100 Subject: [PATCH] add logic for if dest branch doesnt exist --- .github/workflows/copy-content.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/copy-content.yml b/.github/workflows/copy-content.yml index a9a65c2e..09c83a67 100644 --- a/.github/workflows/copy-content.yml +++ b/.github/workflows/copy-content.yml @@ -43,13 +43,29 @@ jobs: uses: actions/checkout@v4 with: path: "source" - - name: Checkout destination repo + + - name: Checkout destination repo (Branch exists) uses: actions/checkout@v4 + if: ${{ steps.check_branch.outputs.branch_exists != 0 }} with: path: "destination" repository: ${{ inputs.repo }} token: ${{ secrets.PAT }} ref: ${{ inputs.branch }} + + - name: Checkout destination repo (Branch doesn't exist) + uses: actions/checkout@v4 + if: ${{ steps.check_branch.outputs.branch_exists == 0 }} + with: + path: "destination" + repository: ${{ inputs.repo }} + token: ${{ secrets.PAT }} + - name: Create branch in destination repo + if: ${{ steps.check_branch.outputs.branch_exists == 0 }} + run: | + cd destination + git checkout -b ${{ inputs.branch }} + - run: echo ${{inputs.prerun}} - name: Run pre-run command if: inputs.prerun != ''