diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca2f5df2..9acb47a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,16 +33,26 @@ jobs: --health-retries=5 steps: - # Generate APP_VERSION dynamically + # Step 1: Set BRANCH_NAME based on event type + - name: Set BRANCH_NAME + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV + else + echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV + fi + + # Step 2: Generate APP_VERSION dynamically - name: Set APP_VERSION run: echo "APP_VERSION=${{ github.sha }}---$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV - # Kirim notifikasi ke API build Start + # Step 3: Kirim notifikasi ke API build Start - name: Notify start build run: | IFS=',' read -ra PHONES <<< "${{ env.WA_PHONE }}" for PHONE in "${PHONES[@]}"; do - curl -X GET "https://wa.wibudev.com/code?text=build-start-${{ env.APP_NAME }}&nom=$PHONE" + ENCODED_TEXT=$(bun -e "console.log(encodeURIComponent('Build:start\nApp:${{ env.APP_NAME }}\nBranch:${{ env.BRANCH_NAME }}\nVersion:${{ env.APP_VERSION }}'))") + curl -X GET "https://wa.wibudev.com/code?text=$ENCODED_TEXT&nom=$PHONE" done # Checkout kode sumber @@ -151,6 +161,6 @@ jobs: run: | IFS=',' read -ra PHONES <<< "${{ env.WA_PHONE }}" for PHONE in "${PHONES[@]}"; do - ENCODED_TEXT=$(bun -e "console.log(encodeURIComponent('Build:${{ env.BUILD_STATUS }}\nApp:${{ env.APP_NAME }}\nVersion:${{ env.APP_VERSION }}\nLog:${{ env.LOG_URL }}'))") + ENCODED_TEXT=$(bun -e "console.log(encodeURIComponent('Build:${{ env.BUILD_STATUS }}\nApp:${{ env.APP_NAME }}\nBranch:${{ env.BRANCH_NAME }}\nVersion:${{ env.APP_VERSION }}\nLog:${{ env.LOG_URL }}'))") curl -X GET "https://wa.wibudev.com/code?text=$ENCODED_TEXT&nom=$PHONE" done