Skip to content

Commit

Permalink
fix(generate.yml): update branch creation logic to use a more concise…
Browse files Browse the repository at this point in the history
… and efficient command for checking branch existence

feat(generate.yml): refactor branch creation step to use dynamic branch names based on inputs.liquibase-version for flexibility and consistency
  • Loading branch information
jandroav committed Mar 5, 2024
1 parent f99d541 commit 34a7f00
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jobs:
- name: Check if feature branch for ${{ inputs.liquibase-version }} exists
id: branch_check
run: |
BRANCH_EXISTS=$(git ls-remote --heads origin feature/protobuf-${{ inputs.liquibase-version }} | wc -l)
echo "::set-output name=branch_exists::$BRANCH_EXISTS"
BRANCH_EXISTS=$(git ls-remote --exit-code --heads origin ${{ inputs.liquibase-version }} &>/dev/null && echo "true" || echo "false")
echo "BRANCH_EXISTS=$BRANCH_EXISTS" >> $GITHUB_ENV
- name: Create or checkout branch for ${{ inputs.liquibase-version }}
- name: Create or checkout branch
run: |
if [ ${{ steps.branch_check.outputs.branch_exists }} -eq 0 ]; then
git checkout -b feature/protobuf-${{ inputs.liquibase-version }}
git push origin feature/protobuf-${{ inputs.liquibase-version }}
if [ "${{ env.BRANCH_EXISTS }}" = "false" ]; then
git checkout -b ${{ inputs.liquibase-version }}
git push origin ${{ inputs.liquibase-version }}
else
git checkout feature/protobuf-${{ inputs.liquibase-version }}
git pull origin feature/protobuf-${{ inputs.liquibase-version }}
git checkout ${{ inputs.liquibase-version }}
git pull origin ${{ inputs.liquibase-version }}
fi
- name: Create feature branch
Expand Down

0 comments on commit 34a7f00

Please sign in to comment.