Skip to content

Commit

Permalink
CI: Carbonix_build.yml split and improve S3 path and fix PR commit_id…
Browse files Browse the repository at this point in the history
… issue
  • Loading branch information
loki077 committed Dec 16, 2024
1 parent ff72844 commit bb195a7
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/carbonix_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bb195a7

Please sign in to comment.