2025-09-14 11:01:33 +03:00
|
|
|
name: Node.js CI / CD (Bun + Forgejo)
|
2025-05-30 12:25:50 -05:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [ "main" ]
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
buildAndRelease:
|
2025-09-14 11:18:13 +03:00
|
|
|
runs-on: codeberg-tiny
|
2025-05-30 12:25:50 -05:00
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v3
|
2025-09-14 11:01:33 +03:00
|
|
|
|
|
|
|
|
- name: Install Bun
|
2025-05-30 12:25:50 -05:00
|
|
|
run: |
|
2025-09-14 11:01:33 +03:00
|
|
|
curl -fsSL https://bun.sh/install | bash
|
|
|
|
|
export BUN_INSTALL="$HOME/.bun"
|
|
|
|
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
|
|
|
|
echo "$BUN_INSTALL/bin" >> $GITHUB_PATH
|
|
|
|
|
|
2025-05-30 12:25:50 -05:00
|
|
|
- name: Install dependencies
|
2025-09-14 11:01:33 +03:00
|
|
|
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
|
|
|
|
|
|
2025-05-30 12:25:50 -05:00
|
|
|
- name: Push JS files to dist branch
|
|
|
|
|
run: |
|
2025-09-14 11:01:33 +03:00
|
|
|
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
|