mirror of
https://github.com/MeshEnvy/mesh-forge.git
synced 2026-03-28 17:42:55 +01:00
refactor: streamline build status updates in GitHub Actions workflow by replacing log calls with a centralized update function
This commit is contained in:
92
.github/workflows/custom_build.yml
vendored
92
.github/workflows/custom_build.yml
vendored
@@ -30,21 +30,36 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CONVEX_URL: ${{ inputs.convex_url }}
|
||||
BUILD_ID: ${{ inputs.build_id }}
|
||||
steps:
|
||||
- name: Log - Build Started
|
||||
- name: Setup status update helper
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "🚀 Build started for ${{ inputs.target }}\n"}'
|
||||
cat > /tmp/update_status.sh << 'EOF'
|
||||
update_status() {
|
||||
curl -sSf -X POST "$CONVEX_URL/github-webhook" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"action\": \"status_update\", \"build_id\": \"$BUILD_ID\", \"status\": \"$1\"}" || true
|
||||
}
|
||||
EOF
|
||||
chmod +x /tmp/update_status.sh
|
||||
|
||||
- name: Update Status - Build Started
|
||||
shell: bash
|
||||
run: |
|
||||
source /tmp/update_status.sh
|
||||
update_status checking_out
|
||||
|
||||
- name: Checkout Web Flasher (this repo)
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log - Checked out web flasher
|
||||
- name: Update Status - Checked Out Web Flasher
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "✓ Checked out web flasher repo\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status checked_out_web_flasher
|
||||
|
||||
- name: Checkout Firmware
|
||||
uses: actions/checkout@v4
|
||||
@@ -55,11 +70,11 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Log - Checked out firmware
|
||||
- name: Update Status - Checked Out Firmware
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "✓ Checked out firmware ${{ inputs.version }}\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status checked_out_firmware
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v4
|
||||
@@ -76,22 +91,28 @@ jobs:
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Log - Installing PlatformIO
|
||||
- name: Update Status - Installing Dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "📦 Installing PlatformIO...\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status installing_dependencies
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install platformio
|
||||
|
||||
- name: Log - Building firmware
|
||||
- name: Update Status - Dependencies Installed
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "🔨 Building firmware for ${{ inputs.target }}...\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status dependencies_installed
|
||||
|
||||
- name: Update Status - Building
|
||||
shell: bash
|
||||
run: |
|
||||
source /tmp/update_status.sh
|
||||
update_status building
|
||||
|
||||
- name: Build Firmware
|
||||
working-directory: firmware
|
||||
@@ -105,16 +126,19 @@ jobs:
|
||||
|
||||
pio run -e ${{ inputs.target }}
|
||||
|
||||
- name: Log - Build complete
|
||||
- name: Update Status - Build Complete
|
||||
if: success()
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "✅ Build completed successfully!\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status build_complete
|
||||
|
||||
- name: Install AWS CLI (for R2)
|
||||
if: success()
|
||||
shell: bash
|
||||
run: |
|
||||
source /tmp/update_status.sh
|
||||
update_status preparing_upload
|
||||
pip install awscli
|
||||
|
||||
- name: Upload to R2
|
||||
@@ -123,7 +147,10 @@ jobs:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
|
||||
shell: bash
|
||||
run: |
|
||||
source /tmp/update_status.sh
|
||||
update_status uploading
|
||||
# Determine file extension based on target (most are .bin, some might be .uf2)
|
||||
BUILD_FILE="firmware/.pio/build/${{ inputs.target }}/firmware.bin"
|
||||
if [ ! -f "$BUILD_FILE" ]; then
|
||||
@@ -136,21 +163,14 @@ jobs:
|
||||
|
||||
echo "✅ Uploaded to R2: ${{ inputs.build_hash }}.uf2"
|
||||
|
||||
- name: Log - Artifact uploaded to R2
|
||||
- name: Update Status - Upload Complete
|
||||
if: success()
|
||||
shell: bash
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "📤 Artifact uploaded to R2: ${{ inputs.build_hash }}.uf2\n"}'
|
||||
source /tmp/update_status.sh
|
||||
update_status upload_complete
|
||||
|
||||
- name: Log - Build failed
|
||||
if: failure()
|
||||
run: |
|
||||
curl -X POST "${{ inputs.convex_url }}/api/logs" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"buildId": "${{ inputs.build_id }}", "logs": "❌ Build failed - check GitHub Actions logs for details\n"}'
|
||||
|
||||
- name: Update Build Status
|
||||
- name: Update Build Status - Final
|
||||
if: always()
|
||||
run: |
|
||||
STATUS="${{ job.status }}"
|
||||
|
||||
Reference in New Issue
Block a user