2021-11-22 17:12:50 +00:00
|
|
|
name: 'Build'
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
on:
|
2021-11-22 17:12:50 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- dev
|
|
|
|
- "release*"
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2023-02-09 14:57:03 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2021-11-22 17:12:50 +00:00
|
|
|
steps:
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Store UID'
|
2021-11-22 17:12:50 +00:00
|
|
|
id: uid
|
|
|
|
run: |
|
2023-04-28 12:33:39 +01:00
|
|
|
echo id="$(id -u $USER)" >> $GITHUB_OUTPUT
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Wipe workspace'
|
|
|
|
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Checkout code'
|
|
|
|
uses: actions/checkout@v3
|
2021-11-22 17:12:50 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2023-04-28 12:33:39 +01:00
|
|
|
submodules: recursive
|
|
|
|
|
|
|
|
- name: 'Setup python'
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Get commit details'
|
2021-11-22 17:12:50 +00:00
|
|
|
id: names
|
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2023-04-28 12:33:39 +01:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2021-11-22 17:12:50 +00:00
|
|
|
else
|
2023-04-28 12:33:39 +01:00
|
|
|
TYPE="other"
|
2021-11-22 17:12:50 +00:00
|
|
|
fi
|
2023-04-28 12:33:39 +01:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
|
|
|
|
echo "event_type=$TYPE" >> $GITHUB_OUTPUT
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Setup node'
|
|
|
|
uses: actions/setup-node@v3
|
2021-11-22 17:12:50 +00:00
|
|
|
with:
|
|
|
|
node-version: '17'
|
|
|
|
cache: 'npm'
|
|
|
|
cache-dependency-path: components/svelte-portal
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Install node dependencies'
|
2021-11-22 17:12:50 +00:00
|
|
|
run: npm install
|
|
|
|
working-directory: components/svelte-portal
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Build captive portal'
|
2021-11-22 17:12:50 +00:00
|
|
|
run: npm run build
|
|
|
|
working-directory: components/svelte-portal
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Build firmware'
|
2021-12-02 14:20:01 +00:00
|
|
|
uses: Intake-Health/esp-idf-ci-action@release-v4.4
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Fix ownership'
|
2021-11-22 17:12:50 +00:00
|
|
|
uses: peter-murray/reset-workspace-ownership-action@v1
|
|
|
|
with:
|
|
|
|
user_id: ${{ steps.uid.outputs.id }}
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Make artifacts directory'
|
2021-11-22 17:12:50 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
run: |
|
2023-04-28 12:33:39 +01:00
|
|
|
rm -rf artifacts
|
2021-11-22 17:12:50 +00:00
|
|
|
mkdir artifacts
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Move upload files'
|
2021-11-22 17:12:50 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
run: |
|
|
|
|
mv build/bootloader/bootloader.bin artifacts/
|
|
|
|
mv build/partition_table/partition-table.bin artifacts/
|
|
|
|
mv build/blackmagic.bin artifacts/
|
2021-11-25 12:29:06 +00:00
|
|
|
cp scripts/flash_nix.sh artifacts/
|
2021-11-22 17:12:50 +00:00
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Generate flash.command file'
|
2021-11-22 17:12:50 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
run: |
|
2023-04-28 12:33:39 +01:00
|
|
|
echo "esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32s2 write_flash $(tr '\n' ' ' < build/flash_args)" > artifacts/flash.command
|
2021-11-22 17:12:50 +00:00
|
|
|
sed -i 's/partition_table\///g' artifacts/flash.command
|
|
|
|
sed -i 's/bootloader\///g' artifacts/flash.command
|
|
|
|
|
2023-04-28 12:33:39 +01:00
|
|
|
- name: 'Generate archive'
|
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
|
|
|
run: |
|
|
|
|
mkdir -p "artifacts-archive"
|
2023-04-28 13:05:57 +01:00
|
|
|
tar -czvf artifacts-archive/blackmagic-firmware-s2-full-${SUFFIX}.tgz -C artifacts/ .
|
2023-04-28 12:33:39 +01:00
|
|
|
|
|
|
|
- name: 'Upload artifacts to update server'
|
2021-11-22 17:12:50 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2021-12-03 11:58:35 +00:00
|
|
|
run: |
|
2023-04-28 12:33:39 +01:00
|
|
|
FILES=$(for CUR in $(ls artifacts-archive/); do echo "-F files=@artifacts-archive/$CUR"; done)
|
|
|
|
curl --fail -L -H "Token: ${{ secrets.INDEXER_TOKEN }}" \
|
|
|
|
-F "branch=${BRANCH_NAME}" \
|
|
|
|
${FILES[@]} \
|
|
|
|
"${{ secrets.INDEXER_UPLOAD_URL }}"
|