Skip to content

chore: change output directory from docs to dist in Vite configuration #4

chore: change output directory from docs to dist in Vite configuration

chore: change output directory from docs to dist in Vite configuration #4

Workflow file for this run

name: Publish dist to GitHub Pages (per-branch, no build)
on:
push:
branches:
- '**' # все ветки
delete: # опциональная очистка при удалении веток (см. второй job ниже)
permissions:
contents: write
jobs:
publish:
if: github.ref_name != 'gh-pages' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute branch slug
id: vars
run: |
BRANCH="${GITHUB_REF_NAME}"
# нормализуем: заменяем слеши и пробелы на '-', нижний регистр, фильтруем лишнее
SLUG="$(printf '%s' "$BRANCH" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's#[/ ]+#-#g; s#[^a-z0-9._-]#-#g; s#-+#-#g; s#(^-|-$)##g')"
echo "slug=$SLUG" >> $GITHUB_OUTPUT
- name: Ensure dist exists
run: |
if [ ! -d dist ]; then
echo "Folder 'dist' not found. Commit your built assets to dist/." >&2
exit 1
fi
# SPA fallback (не билд, просто копия)
[ -f dist/index.html ] && cp -f dist/index.html dist/404.html || true
# main --> корень gh-pages. ВАЖНО: clean=false, чтобы не снести подпапки других веток.
- name: Deploy main to root
if: steps.vars.outputs.slug == 'main'
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: dist
clean: false # не чистим весь корень, сохраняем подпапки других веток
# другие ветки --> gh-pages/<branch>
- name: Deploy branch to subfolder
if: steps.vars.outputs.slug != 'main'
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: dist
target-folder: ${{ steps.vars.outputs.slug }}
clean: true # чистим ТОЛЬКО свою подпапку