name: "Build and Deploy" on: push: branches: - "master" - "main" pull_request: branches: - "master" - "main" env: IS_PUSH: ${{ github.event_name == 'push' }} IS_MAIN: ${{ github.event.repository.default_branch == github.ref_name }} jobs: build: name: "Build and Deploy" runs-on: ubuntu-latest container: # image: ubuntu:latest options: --volume "${{ secrets.NGINX_HTML_DIRECTORY }}:/usr/share/nginx/html: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 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: meta run: | branchName=${GITHUB_REF#refs/heads/} version=$(date +"%y%m.%d.%H%M%S") tagName=$version preRelease=false if [[ ${{ env.IS_MAIN }} == "false" ]]; 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.meta.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/html/fpv; cp -rf public/* /usr/share/nginx/html/fpv