name: Build and Deploy on: push: branches: - 'master' - 'main' pull_request: branches: - 'master' - 'main' jobs: build: name: Build and Deploy runs-on: ubuntu-latest container: options: --volume "nginx_static:/usr/share/nginx/static:rw" steps: - name: Checkout uses: actions/checkout@v4 with: # lfs: true persist-credentials: true - # https://gitea.com/gitea/act_runner/issues/164#issuecomment-739652 name: Checkout LFS run: | git lfs install --local AUTH=$(git config --get --local http.${{ github.server_url }}/.extraheader) git config --local --unset http.${{ github.server_url }}/.extraheader git config --local http.${{ github.server_url }}/batch.extraheader "$AUTH" git lfs fetch git lfs checkout - name: Get Metadata id: metadata run: | branchName=${GITHUB_REF#refs/heads/} version=$(date +"%y%m.%d.%H%M%S") tagName=$version preRelease=false if [[ "$branchName" != "master" && "$branchName" != "main" ]]; then tagName="$tagName-$branchName" preRelease=true fi echo "BRANCH_NAME = $branchName" echo "VERSION = $version" echo "TAG_NAME = $tagName" echo "PRERELEASE = $preRelease" echo "BRANCH_NAME=$branchName" >> $GITHUB_OUTPUT echo "VERSION=$version" >> $GITHUB_OUTPUT echo "TAG_NAME=$tagName" >> $GITHUB_OUTPUT echo "PRERELEASE=$preRelease" >> $GITHUB_OUTPUT - name: Setup pnpm uses: pnpm/action-setup@v4.0.0 - name: Install dependencies run: pnpm install - name: Compile Sass and minify CSS and Javascript run: pnpm run build - name: Append version query arg to asset URLs env: VERSION: ${{ steps.metadata.outputs.VERSION }} run: | echo "VERSION = $VERSION" find public -type f -name '*.html' -exec sed -i "s/\"\([^\"?]\+\.css\)\"/\"\1?v=$VERSION\"/g" {} + find public -type f -name '*.html' -exec sed -i "s/\"\([^\"?]\+\.js\)\"/\"\1?v=$VERSION\"/g" {} + - name: Minify HTML run: | pnpm html-minifier-terser --collapse-whitespace --minify-css --minify-js --remove-comments --input-dir public --output-dir public --file-ext html - name: Copy files to public folder run: mkdir -p /usr/share/nginx/static/fpv; cp -rf public/* /usr/share/nginx/static/fpv