|
| 1 | +name: Build ELXR12 DLStreamer Image |
| 2 | +on: |
| 3 | + workflow_dispatch: # Manual runs |
| 4 | + inputs: |
| 5 | + ref: |
| 6 | + description: "Branch or SHA to test (e.g. feature/x or a1b2c3)" |
| 7 | + required: false |
| 8 | + run_qemu_test: |
| 9 | + description: "Run QEMU boot test after build" |
| 10 | + required: false |
| 11 | + default: "false" |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - "true" |
| 15 | + - "false" |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-elxr12-dlstreamer: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + ref: ${{ github.event.inputs.ref || github.ref }} |
| 34 | + persist-credentials: false |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + |
| 39 | + - name: Install Earthly |
| 40 | + uses: earthly/actions-setup@v1 |
| 41 | + with: |
| 42 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + version: "latest" |
| 44 | + |
| 45 | + - name: Install system deps |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y qemu-system-x86 ovmf tree jq systemd-ukify mmdebstrap systemd-boot |
| 49 | +
|
| 50 | + - name: Set up Go |
| 51 | + uses: actions/setup-go@v5 |
| 52 | + with: |
| 53 | + go-version: stable |
| 54 | + |
| 55 | + - name: Prepare build script |
| 56 | + run: | |
| 57 | + if [ ! -f scripts/build_elxr12_dlstreamer.sh ]; then |
| 58 | + echo "scripts/build_elxr12_dlstreamer.sh not found!" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | + chmod +x scripts/build_elxr12_dlstreamer.sh |
| 62 | +
|
| 63 | + - name: Run ELXR12 DLStreamer Image Build |
| 64 | + env: |
| 65 | + RUN_QEMU_TEST: ${{ github.event.inputs.run_qemu_test }} |
| 66 | + run: | |
| 67 | + echo "Starting ELXR12 DLStreamer image build..." |
| 68 | + # Ensure script has access to docker group for Earthly |
| 69 | + sudo usermod -aG docker $USER |
| 70 | + |
| 71 | + # Prepare arguments with input validation |
| 72 | + ARGS="" |
| 73 | + case "${RUN_QEMU_TEST}" in |
| 74 | + "true") |
| 75 | + ARGS="--qemu-test" |
| 76 | + echo "QEMU boot test will be run after build" |
| 77 | + ;; |
| 78 | + "false"|"") |
| 79 | + echo "QEMU boot test will be skipped" |
| 80 | + ;; |
| 81 | + *) |
| 82 | + echo "Invalid input for run_qemu_test: ${RUN_QEMU_TEST}" |
| 83 | + exit 1 |
| 84 | + ;; |
| 85 | + esac |
| 86 | + |
| 87 | + # Run the ELXR12 DLStreamer image build script |
| 88 | + ./scripts/build_elxr12_dlstreamer.sh $ARGS |
| 89 | + echo "ELXR12 DLStreamer image build completed." |
| 90 | +
|
| 91 | + - name: Notify on failure |
| 92 | + if: ${{ failure() && github.event_name == 'pull_request' }} |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + REVIEWER_ID: srmungar |
| 96 | + run: | |
| 97 | + PR_AUTHOR=$(jq --raw-output 'try .pull_request.user.login // empty' "$GITHUB_EVENT_PATH") |
| 98 | + if [ -z "$PR_AUTHOR" ]; then |
| 99 | + echo "PR_AUTHOR not found in event payload. Skipping notification." |
| 100 | + exit 0 |
| 101 | + fi |
| 102 | + COMMENT_BODY="Hey @$PR_AUTHOR and @$REVIEWER_ID — the ELXR12 DLStreamer image build has failed. Please check the logs." |
| 103 | + curl -s -X POST \ |
| 104 | + -H "Authorization: Bearer $GITHUB_TOKEN" \ |
| 105 | + -H "Accept: application/vnd.github.v3+json" \ |
| 106 | + --data "{\"body\": \"$COMMENT_BODY\"}" \ |
| 107 | + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |
0 commit comments