mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
124 lines
4.9 KiB
YAML
124 lines
4.9 KiB
YAML
name: Sync upstream & build custom cabinet static
|
||
|
||
# Подтягивает апстрим BEDOLAGA-DEV/bedolaga-cabinet поверх нашего форка,
|
||
# накатывает локальный патч (см. src/pages/Subscription.tsx), собирает
|
||
# фронтенд и публикует статику как GitHub Release-ассет.
|
||
# Если апстрим правил тот же кусок, что и наш патч — merge упадёт с
|
||
# конфликтом, и это НАМЕРЕННО: незнакомый код от стороннего разработчика
|
||
# не должен автоматически домёрживаться без ручной проверки.
|
||
|
||
on:
|
||
schedule:
|
||
- cron: '0 6 * * *' # ежедневно в 06:00 UTC; GitHub может отключить
|
||
# cron-триггер после ~60 дней без активности в репозитории —
|
||
# тогда просто запустите workflow вручную (workflow_dispatch).
|
||
workflow_dispatch: {}
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
concurrency:
|
||
group: sync-and-build
|
||
cancel-in-progress: false
|
||
|
||
env:
|
||
UPSTREAM_REPO: https://github.com/BEDOLAGA-DEV/bedolaga-cabinet.git
|
||
|
||
jobs:
|
||
sync-and-build:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout fork
|
||
uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Configure git identity
|
||
run: |
|
||
git config user.name "github-actions[bot]"
|
||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||
|
||
- name: Fetch and merge upstream
|
||
id: sync
|
||
run: |
|
||
BEFORE=$(git rev-parse HEAD)
|
||
git remote add upstream "$UPSTREAM_REPO"
|
||
git fetch upstream main
|
||
git merge --no-edit upstream/main
|
||
AFTER=$(git rev-parse HEAD)
|
||
if [ "$BEFORE" != "$AFTER" ]; then
|
||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||
else
|
||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||
fi
|
||
|
||
- name: Strip upstream-only CI/CD files
|
||
# Апстрим хранит у себя dependabot.yml и CI-workflow'ы, которых нам
|
||
# не нужно в приватном форке (плодят PR/раны, требуют чужих секретов).
|
||
# Merge может притащить их обратно — вычищаем перед пушем.
|
||
if: steps.sync.outputs.changed == 'true'
|
||
run: |
|
||
FILES=(
|
||
.github/dependabot.yml
|
||
.github/workflows/ci.yml
|
||
.github/workflows/codeql.yml
|
||
.github/workflows/docker.yml
|
||
.github/workflows/lint.yml
|
||
.github/workflows/release-please.yml
|
||
.github/workflows/release.yml
|
||
.github/workflows/security-audit.yml
|
||
)
|
||
REMOVED=false
|
||
for f in "${FILES[@]}"; do
|
||
if [ -e "$f" ]; then
|
||
git rm -q "$f"
|
||
REMOVED=true
|
||
fi
|
||
done
|
||
if [ "$REMOVED" = true ]; then
|
||
git commit -q -m "chore: strip upstream CI/CD workflows not needed in this fork"
|
||
fi
|
||
|
||
- name: Push merged main back to fork
|
||
if: steps.sync.outputs.changed == 'true'
|
||
run: git push origin HEAD:main
|
||
|
||
- name: Set up Node
|
||
if: steps.sync.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: 20
|
||
|
||
- name: Install dependencies
|
||
if: steps.sync.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
|
||
run: npm ci
|
||
|
||
- name: Build frontend
|
||
if: steps.sync.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
|
||
# Те же build-args, что использует официальный образ (см. docker.yml) —
|
||
# чтобы поведение совпадало с тем, что уже стоит на VPS.
|
||
run: npm run build:docker
|
||
env:
|
||
VITE_API_URL: /api
|
||
VITE_TELEGRAM_BOT_USERNAME: ''
|
||
VITE_APP_NAME: Cabinet
|
||
VITE_APP_LOGO: V
|
||
|
||
- name: Package dist
|
||
if: steps.sync.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
|
||
run: |
|
||
cd dist
|
||
tar -czf ../cabinet-dist.tar.gz .
|
||
|
||
- name: Publish release
|
||
if: steps.sync.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
|
||
env:
|
||
GH_TOKEN: ${{ github.token }}
|
||
run: |
|
||
TAG="build-$(date -u +%Y%m%d-%H%M%S)-$(git rev-parse --short HEAD)"
|
||
gh release create "$TAG" cabinet-dist.tar.gz \
|
||
--repo "$GITHUB_REPOSITORY" \
|
||
--title "$TAG" \
|
||
--notes "Автосборка: апстрим синхронизирован + локальный патч (скрыт блок «Дополнительные опции»)." \
|
||
--latest
|