name: Node.js CI / CD (Bun + Forgejo) on: push: branches: [ "main", "dev" ] jobs: buildAndRelease: runs-on: codeberg-tiny steps: - uses: actions/checkout@v3 - name: Install Bun run: | curl -fsSL https://bun.sh/install | bash export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" echo "$BUN_INSTALL/bin" >> $GITHUB_PATH - name: Install dependencies run: | export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" bun install - name: Build project run: | export BUN_INSTALL="$HOME/.bun" export PATH="$BUN_INSTALL/bin:$PATH" bun run build --release-branch=${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}} --build-minify - name: Push JS files to dist branch run: | git config --local user.email "actions@forgejo.local" git config --local user.name "Forgejo Actions" mkdir -p temp_dist find dist -name "*.js" -exec cp {} temp_dist/ \; git checkout --orphan dist-temp git rm -rf --cached . cp -r temp_dist/* . rm -rf temp_dist git add *.js git commit -m "Update build $GITHUB_SHA" || exit 0 if [ "${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}}" = "dev" ]; then TARGET_BRANCH="testing-dist" else TARGET_BRANCH="dist" fi git push -f origin HEAD:$TARGET_BRANCH git checkout -f ${GITHUB_REF_NAME:-${CI_COMMIT_REF_NAME}} - name: Merge main into github if: github.ref == 'refs/heads/main' run: | git config --local user.email "actions@forgejo.local" git config --local user.name "Forgejo Actions" git fetch origin git checkout github || git checkout -b github git merge origin/main --no-edit --allow-unrelated-histories git push --force origin github