Optimize LFS Usage in Builds (#596) #116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build SquashFS Image | |
on: | |
workflow_dispatch: | |
inputs: | |
debos_branch: | |
type: string | |
description: neon_debos branch to use | |
push: | |
branches: | |
- dev | |
- master | |
paths-ignore: | |
- 'neon_core/version.py' | |
- 'CHANGELOG.md' | |
jobs: | |
build_squashfs_image: | |
runs-on: 2222.us | |
steps: | |
- name: Get debos repo branch | |
id: branch | |
run: | | |
DEFAULT_REF=${{ github.ref }} | |
REQUEST_REF=${{ github.event.inputs.debos_branch }} | |
echo "::set-output name=debos::${REQUEST_REF:-${DEFAULT_REF}}" | |
- name: Checkout Debos Repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.branch.outputs.debos }} | |
lfs: True | |
repository: NeonGeckoCom/neon_debos | |
path: action/neon_debos | |
- name: Create LFS file list | |
run: | | |
cd action/neon_debos | |
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
cd ../.. | |
- name: Restore LFS cache | |
uses: actions/cache@v3 | |
id: lfs-cache | |
with: | |
path: action/neon_debos/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | |
- name: Ensure LFS files are pulled | |
if: steps.lfs-cache.outputs.cache-hit != 'true' | |
run: | | |
cd action/neon_debos | |
git lfs pull | |
cd ../.. | |
- name: Save LFS Cache | |
if: steps.lfs-cache.outputs.cache-hit != 'true' | |
id: lfs-cache-save | |
uses: actions/cache/save@v3 | |
with: | |
path: action/neon_debos/.git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | |
- name: Export keys for image build | |
run: | | |
mkdir -p action/neon_debos/overlays/80-google-json-overlay/home/neon/.local/share/neon | |
echo ${GOOGLE_KEY}>action/neon_debos/overlays/80-google-json-overlay/home/neon/.local/share/neon/google.json | |
env: | |
GOOGLE_KEY: ${{secrets.google_api_key}} | |
- name: Build and Export Mk2 Image | |
run: | | |
bash action/neon_debos/run_automation.sh debian-neon-image.yml ${{ github.ref_name }} /var/www/html/app/files/neon_images/pi/mycroft_mark_2 rpi4 mark_2 | |
- name: Build and Export OPi5 Image | |
run: | | |
bash action/neon_debos/run_automation.sh debian-neon-image.yml ${{ github.ref_name }} /var/www/html/app/files/neon_images/orange_pi_5/ opi5 opi5 | |
- name: Stop Docker Build Containers | |
if: failure() || cancelled() | |
run: | | |
docker kill neon_debos_ghaction |