2023-11-19 14:08:26 +00:00
|
|
|
name: BTClock WebUI CI
|
|
|
|
|
|
|
|
on: [push]
|
|
|
|
|
|
|
|
env:
|
|
|
|
PUBLIC_BASE_URL: ""
|
|
|
|
|
|
|
|
jobs:
|
2023-11-19 14:54:44 +00:00
|
|
|
check-changes:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
continue-on-error: true
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Get changed files count
|
|
|
|
id: changed-files
|
|
|
|
uses: tj-actions/changed-files@v40.1.1
|
|
|
|
|
|
|
|
- name: Print changed files count
|
2023-11-19 15:02:06 +00:00
|
|
|
run: >
|
|
|
|
echo "Changed files count: ${{
|
|
|
|
steps.changed-files.outputs.all_changed_and_modified_files_count }}"
|
2023-11-19 14:54:44 +00:00
|
|
|
|
|
|
|
- name: Fail if less than 2 changes detected
|
2023-11-19 15:02:06 +00:00
|
|
|
if: steps.changed-files.outputs.all_changed_and_modified_files_count < 2
|
|
|
|
run: exit 1
|
2023-11-19 14:54:44 +00:00
|
|
|
|
2023-11-19 14:08:26 +00:00
|
|
|
build:
|
2023-11-19 14:54:44 +00:00
|
|
|
needs: check-changes
|
2023-11-19 14:08:26 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-11-19 14:54:44 +00:00
|
|
|
if: ${{ needs.check-changes.result == 'success' }}
|
2023-11-19 14:08:26 +00:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: lts/*
|
|
|
|
cache: yarn
|
|
|
|
cache-dependency-path: '**/yarn.lock'
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/pip
|
|
|
|
~/node_modules
|
|
|
|
key: ${{ runner.os }}-pio
|
|
|
|
- uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.9'
|
|
|
|
- name: Get current date
|
|
|
|
id: dateAndTime
|
2023-11-19 14:21:38 +00:00
|
|
|
run: echo "dateAndTime=$(date +'%Y-%m-%d-%H:%M')" >> $GITHUB_OUTPUT
|
2023-11-19 14:08:26 +00:00
|
|
|
- name: Install mklittlefs
|
|
|
|
run: >
|
2023-11-19 14:12:14 +00:00
|
|
|
git clone https://github.com/earlephilhower/mklittlefs.git /tmp/mklittlefs &&
|
|
|
|
cd /tmp/mklittlefs &&
|
|
|
|
git submodule update --init &&
|
2023-11-19 14:08:26 +00:00
|
|
|
make dist
|
|
|
|
- name: Install yarn
|
2023-11-19 14:18:37 +00:00
|
|
|
run: yarn && yarn postinstall
|
2023-11-19 14:08:26 +00:00
|
|
|
- name: Build WebUI
|
|
|
|
run: yarn build
|
2023-11-19 14:36:25 +00:00
|
|
|
- name: Get current block
|
|
|
|
id: getBlockHeight
|
|
|
|
run: echo "blockHeight=$(curl -s https://mempool.space/api/blocks/tip/height)" >> $GITHUB_OUTPUT
|
2023-11-19 14:08:26 +00:00
|
|
|
- name: gzip build for LittleFS
|
|
|
|
run: find dist -type f ! -name ".*" -exec sh -c 'mkdir -p "build_gz/$(dirname "${1#dist/}")" && gzip -k "$1" -c > "build_gz/${1#dist/}".gz' _ {} \;
|
|
|
|
- name: Create tarball
|
|
|
|
run: tar czf webui.tgz --strip-components=1 dist
|
|
|
|
- name: Build LittleFS
|
2023-11-19 14:09:51 +00:00
|
|
|
run: /tmp/mklittlefs/mklittlefs -c build_gz -s 409600 littlefs.bin
|
2023-11-19 14:08:26 +00:00
|
|
|
- name: Upload artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
webui.tgz
|
|
|
|
littlefs.bin
|
|
|
|
- name: Create release
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
2023-11-19 14:40:41 +00:00
|
|
|
tag: ${{ steps.getBlockHeight.outputs.blockHeight }}
|
2023-11-19 14:18:37 +00:00
|
|
|
commit: main
|
2023-11-19 14:36:25 +00:00
|
|
|
name: release-${{ steps.getBlockHeight.outputs.blockHeight }}
|
2023-11-19 14:08:26 +00:00
|
|
|
artifacts: "littlefs.bin,webui.tgz"
|
|
|
|
allowUpdates: true
|
|
|
|
removeArtifacts: true
|
|
|
|
makeLatest: true
|