GoonCord/.forgejo/workflows/build.yaml

56 lines
2 KiB
YAML
Raw Normal View History

name: Node.js CI / CD (Bun + Forgejo)
on:
push:
2025-10-12 21:32:35 +03:00
branches: [ "main", "dev" ]
jobs:
buildAndRelease:
2025-09-14 11:18:13 +03:00
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
2025-10-12 21:32:35 +03:00
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
2025-09-14 11:20:49 +03:00
git merge origin/main --no-edit --allow-unrelated-histories
2025-09-14 11:25:31 +03:00
git push --force origin github