diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index b4cd5acca3..10914261f9 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -135,6 +135,52 @@ concurrency: cancel-in-progress: true jobs: + setup-s3-path: + runs-on: ubuntu-22.04 + if: ${{ !contains(github.event.pull_request.labels.*.name, 'SKIP_BUILD') }} + outputs: + s3_path: ${{ steps.set-s3-path.outputs.s3_path }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract firmware version, commit id, and branch name + id: extract_info + run: | + FIRMWARE_VERSION=$(grep -oP 'define AP_CUSTOM_FIRMWARE_STRING "\K(.*)(?=")' libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/version.inc) + if [ "${{ github.event_name }}" == "pull_request" ]; then + COMMIT_ID=$(git rev-parse --short ${{ github.event.pull_request.head.sha }}) + else + COMMIT_ID=$(git rev-parse --short HEAD) + fi + BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) + echo "firmware_version=$FIRMWARE_VERSION" >> $GITHUB_ENV + echo "commit_id=$COMMIT_ID" >> $GITHUB_ENV + echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV + shell: bash + + - name: Set S3 Path + id: set-s3-path + run: | + DATE_HR=$(date +%Y%m%d_%H%M) + if [ "${{ github.event_name }}" == "release" ]; then + PATH_TO_S3=s3://carbonix-firmware-release-files/Carbopilot_V2/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ + echo "Release to: $PATH_TO_S3" + elif [ "${{ github.event_name }}" == "push" ] && [[ "${{ env.branch_name }}" == CxPilot* ]]; then + PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/${{ env.branch_name }}/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/ + echo "PUSH : $PATH_TO_S3" + elif [ "${{ github.event_name }}" == "pull_request" ]; then + PATH_TO_S3=s3://carbonix-firmware-dev-files/Carbopilot_V2/PR/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}_${{ github.event.pull_request.number }}/ + echo "PR : $PATH_TO_S3" + else + PATH_TO_S3="s3://carbonix-firmware-dev-files/Carbopilot_V2/Manual/${DATE_HR}_${{ env.firmware_version }}_${{ env.commit_id }}/" + echo "Manual trigger or other: $PATH_TO_S3" + fi + echo "::set-output name=s3_path::$PATH_TO_S3" + shell: bash + build-sitl: runs-on: 'windows-latest' steps: