From 6a7c3df3df98eb84d7b8c4f5cd0b000f8a62d9ff Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Wed, 24 Jan 2024 17:22:34 +0100 Subject: [PATCH] GHA: Create new metarepo branch when it does not exist. --- .github/workflows/cd-libs-metadata.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd-libs-metadata.yml b/.github/workflows/cd-libs-metadata.yml index f43453b8..54aa24b2 100644 --- a/.github/workflows/cd-libs-metadata.yml +++ b/.github/workflows/cd-libs-metadata.yml @@ -29,6 +29,11 @@ on: default: '' description: Target repo to sync changes. type: string + TARGET_REPO_DEFAULT_BRANCH: + required: false + default: 'main' + description: Target repo default branch name. + type: string TARGET_OS: required: true default: '' @@ -65,9 +70,9 @@ jobs: environment: ${{ inputs.ENVIRONMENT }} steps: - - name: Checkout metadatarepo + - name: Checkout metadatarepo (${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }}) uses: actions/checkout@v4 - continue-on-error: false + continue-on-error: true id: metabranch with: repository: ${{ inputs.TARGET_REPO }} @@ -75,16 +80,18 @@ jobs: ssh-key: ${{ secrets.GH_BOT_DEPLOY_KEY }} token: ${{ secrets.GH_BOT_DEPLOY_TOKEN || github.token }} - - name: Checkout metadatarepo + - name: Checkout metadatarepo (${{ inputs.TARGET_REPO_DEFAULT_BRANCH }}) uses: actions/checkout@v4 if: steps.metabranch.outcome != 'success' with: repository: ${{ inputs.TARGET_REPO }} + ref: ${{ inputs.TARGET_REPO_DEFAULT_BRANCH }} ssh-key: ${{ secrets.GH_BOT_DEPLOY_KEY }} token: ${{ secrets.GH_BOT_DEPLOY_TOKEN || github.token }} + clean: true - name: Create remote - continue-on-error: true + if: steps.metabranch.outcome != 'success' run: | git checkout -b ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }} git push --set-upstream origin ${{ inputs.LIB_NAME }}/${{ inputs.TARGET_OS }}/${{ inputs.TARGET_PLATFORM }}