Browse Source

Add in our actions

Eric Helgeson 4 tháng trước cách đây
mục cha
commit
946a10c4b3
2 tập tin đã thay đổi với 123 bổ sung0 xóa
  1. 54 0
      .github/workflows/analyze_crashlogs.yml
  2. 69 0
      .github/workflows/firmware_build.yml

+ 54 - 0
.github/workflows/analyze_crashlogs.yml

@@ -0,0 +1,54 @@
+name: Analyze crash logs
+
+on:
+  issue_comment:
+    types: [created]
+  issues:
+    types: [opened, edited]
+
+jobs:
+  analyze_crashlog:
+    name: Analyze crash log
+    runs-on: ubuntu-20.04
+    if: |
+      (github.event_name == 'issue_comment' && (
+        contains(github.event.comment.body, 'CRASH') ||
+        contains(github.event.comment.body, 'WATCHDOG'))) ||
+      (github.event_name == 'issues' && (
+          contains(github.event.issue.body, 'CRASH') ||
+          contains(github.event.issue.body, 'WATCHDOG')))
+    permissions:
+      issues: write
+
+    steps:
+      - name: Check out code from GitHub
+        uses: actions/checkout@v3
+
+      - name: Install tools
+        run: |
+          sudo apt-get install binutils-arm-none-eabi
+
+      - name: Analyze crash log from issue body
+        if: github.event_name == 'issues'
+        env:
+          ISSUE_ID: ${{ github.event.issue.number }}
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          gh api repos/${GITHUB_REPOSITORY}/issues/${ISSUE_ID}/comments --jq '.[-1].body' | grep Automatic && exit 0 # Comment only once
+          gh api repos/${GITHUB_REPOSITORY}/issues/${ISSUE_ID} --jq '.body' > comment.txt
+          echo -e 'Automatic analysis of the crash log:\n\n<pre>' > output.txt
+          utils/analyze_crashlog.sh comment.txt | tee -a output.txt
+          echo '</pre>' >> output.txt
+          grep '^0x' output.txt && gh issue comment ${ISSUE_ID} --body-file output.txt
+
+      - name: Analyze crash log from issue comment
+        if: github.event_name == 'issue_comment'
+        env:
+          ISSUE_ID: ${{ github.event.issue.number }}
+          GH_TOKEN: ${{ github.token }}
+        run: |
+          gh api repos/${GITHUB_REPOSITORY}/issues/${ISSUE_ID}/comments --jq '.[-1].body' > comment.txt
+          echo -e 'Automatic analysis of the crash log:\n\n<pre>' > output.txt
+          utils/analyze_crashlog.sh comment.txt | tee -a output.txt
+          echo '</pre>' >> output.txt
+          grep '^0x' output.txt && gh issue comment ${ISSUE_ID} --body-file output.txt

+ 69 - 0
.github/workflows/firmware_build.yml

@@ -0,0 +1,69 @@
+name: Build BlueSCSI firmware
+
+on:
+  push:
+  pull_request:
+  workflow_dispatch:
+
+jobs:
+  build_firmware:
+    name: Build firmware on Ubuntu
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Check out code from GitHub
+        uses: actions/checkout@v4
+        with:
+          path: BlueSCSI
+          fetch-depth: "0"
+      - uses: actions/cache@v4
+        with:
+          path: |
+            ~/.cache/pip
+            ~/.platformio/.cache
+          key: ${{ runner.os }}-pio
+
+      - uses: actions/setup-python@v5
+        with:
+          python-version: '3.11'
+
+      - name: Install platformio
+        run: |
+          pip install --upgrade platformio
+
+      - name: Build firmware
+        run: |
+          cd BlueSCSI
+          pio run -v -e BlueSCSI_Pico_DaynaPORT -e BlueSCSI_Pico_2_DaynaPORT
+
+      - name: Rename firmware files
+        run: |
+          cd BlueSCSI
+          utils/rename_binaries.sh
+
+      - name: Upload binaries into build artifacts
+        uses: actions/upload-artifact@v4
+        with:
+          path: BlueSCSI/distrib/*
+          name: BlueSCSI binaries
+
+      - name: Upload to latest release
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        if: ${{ github.ref == 'refs/heads/main' && github.repository == 'BlueSCSI/BlueSCSI-v2' }}
+        run: |
+          cd BlueSCSI
+          git tag -d latest
+          git tag latest
+          git push origin --force latest
+          cd distrib
+          gh api repos/${GITHUB_REPOSITORY}/releases/tags/latest | jq -r '.assets[] | [.url] | @tsv' | xargs -n 1 gh api -X DELETE || true
+          gh release upload --repo ${GITHUB_REPOSITORY} --clobber latest *
+
+      - name: Upload to newly created release
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository == 'BlueSCSI/BlueSCSI-v2' }}
+        run: |
+          RELEASE=$(basename ${{github.ref}})
+          gh release create --repo ${GITHUB_REPOSITORY} -t $RELEASE $RELEASE BlueSCSI/distrib/*