GoonCord/.forgejo/workflows/build.yaml

61 lines
No EOL
1.7 KiB
YAML

name: Node.js CI / CD (Bun + Forgejo)
on:
push:
branches: [ "main" ]
jobs:
buildAndRelease:
runs-on: ubuntu-latest
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
git push -f origin HEAD:dist
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
git push origin github