diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dbc9c77..fcbb4f6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,11 +29,19 @@ jobs: - name: Use local branch shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + HEAD_REF: ${{ github.head_ref }} + REF_NAME: ${{ github.ref_name }} run: | - BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}") - git branch -D $BRANCH 2>/dev/null || true - git branch $BRANCH HEAD - git checkout $BRANCH + if [ "$EVENT_NAME" = "pull_request" ]; then + BRANCH="$HEAD_REF" + else + BRANCH="$REF_NAME" + fi + git branch -D "$BRANCH" 2>/dev/null || true + git branch "$BRANCH" HEAD + git checkout "$BRANCH" - name: Install PHP uses: shivammathur/setup-php@v2 @@ -60,11 +68,19 @@ jobs: - name: Use local branch shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + HEAD_REF: ${{ github.head_ref }} + REF_NAME: ${{ github.ref_name }} run: | - BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}") - git branch -D $BRANCH 2>/dev/null || true - git branch $BRANCH HEAD - git checkout $BRANCH + if [ "$EVENT_NAME" = "pull_request" ]; then + BRANCH="$HEAD_REF" + else + BRANCH="$REF_NAME" + fi + git branch -D "$BRANCH" 2>/dev/null || true + git branch "$BRANCH" HEAD + git checkout "$BRANCH" - name: Install PHP uses: shivammathur/setup-php@v2 @@ -102,11 +118,19 @@ jobs: - name: Use local branch shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + HEAD_REF: ${{ github.head_ref }} + REF_NAME: ${{ github.ref_name }} run: | - BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}") - git branch -D $BRANCH 2>/dev/null || true - git branch $BRANCH HEAD - git checkout $BRANCH + if [ "$EVENT_NAME" = "pull_request" ]; then + BRANCH="$HEAD_REF" + else + BRANCH="$REF_NAME" + fi + git branch -D "$BRANCH" 2>/dev/null || true + git branch "$BRANCH" HEAD + git checkout "$BRANCH" - name: Install PHP with extensions uses: shivammathur/setup-php@v2 @@ -152,11 +176,19 @@ jobs: - name: Use local branch shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + HEAD_REF: ${{ github.head_ref }} + REF_NAME: ${{ github.ref_name }} run: | - BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}") - git branch -D $BRANCH 2>/dev/null || true - git branch $BRANCH HEAD - git checkout $BRANCH + if [ "$EVENT_NAME" = "pull_request" ]; then + BRANCH="$HEAD_REF" + else + BRANCH="$REF_NAME" + fi + git branch -D "$BRANCH" 2>/dev/null || true + git branch "$BRANCH" HEAD + git checkout "$BRANCH" - name: Install PHP with extensions uses: shivammathur/setup-php@v2