From 6888f8298412609fe1fc53e6ad2d9e0ddd5b6930 Mon Sep 17 00:00:00 2001 From: Lokesh-Ramina Date: Sun, 26 May 2024 22:44:42 -0700 Subject: [PATCH] workflow: Carbonix_build: push data to AWS S3 This mods will push the data in 3 category Folder name is modified with pre fix of UTC dat, time, branch name, commit ID and PR id Folder Directory: Release: carbonix-firmware-release-files/Carbopilot_V2 Merge to CxPilot : carbonix-firmware-dev-files/Carbopilot_V2/CxPilot*/ Others: carbonix-firmware-dev-files/Carbopilot_V2/PR SW-199 --- .github/workflows/carbonix_build.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/carbonix_build.yml b/.github/workflows/carbonix_build.yml index 411a6bed2e..d412e3512d 100644 --- a/.github/workflows/carbonix_build.yml +++ b/.github/workflows/carbonix_build.yml @@ -125,6 +125,9 @@ on: - '.vscode/**' - '.github/ISSUE_TEMPLATE/**' + release: + types: [published] + workflow_dispatch: concurrency: @@ -209,3 +212,38 @@ jobs: name: compiled-output path: build-output.zip retention-days: 90 + + - name: Install AWS CLI + run: | + sudo apt-get update + sudo apt-get install -y curl unzip + curl "https://d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Set BRANCH_NAME + run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV + + - name: Upload artifacts to S3 + 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 "Uploading to: $PATH_TO_S3" + aws s3 cp temp/ $PATH_TO_S3 --recursive + elif ${{ github.event_name == 'push' && startsWith(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 "Uploading to: $PATH_TO_S3" + aws s3 cp temp/ $PATH_TO_S3 --recursive + 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 "Uploading to: $PATH_TO_S3" + aws s3 cp temp/ $PATH_TO_S3 --recursive + fi