Меняет партнёрский блок #440
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Preview | |
on: | |
pull_request_target | |
jobs: | |
preview: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.draft == false }} | |
env: | |
DEPLOY_DOMAIN: https://platform-${{ github.event.pull_request.number }}.dev.doka.guide | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PATH_TO_CONTENT: ./content | |
steps: | |
- name: Загрузка платформы | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Загрузка контента | |
uses: actions/checkout@v4 | |
with: | |
repository: doka-guide/content | |
path: content | |
- name: Загрузка кеша | |
uses: actions/checkout@v2 | |
with: | |
repository: doka-guide/cache | |
path: cache | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Кэширование модулей | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Получение идентификатора | |
id: check | |
if: ${{ env.SURGE_TOKEN != '' }} | |
run: | | |
check_suite_url=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r '.check_suite_url') | |
check_run_id=$(curl -s -H "Accept: application/vnd.github.v3+json" $check_suite_url/check-runs | jq '.check_runs[] | .id') | |
echo "::set-output name=check_id::$check_run_id" | |
- name: Установка модулей | |
run: npm ci | |
- name: Копирование кеша | |
run: cp ./cache/issues.json ./.issues.json | |
- name: Сообщение о начале публикации превью | |
uses: hasura/comment-progress@v2.1.0 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.pull_request.number }} | |
id: preview-${{ github.event.pull_request.number }} | |
message: "Идёт сборка и публикация превью... [Подробнее](https://github.com/${{ github.repository }}/runs/${{ steps.check.outputs.check_id }}?check_suite_focus=true)" | |
recreate: true | |
- name: Установка ключа для пользователя | |
run: | | |
set -eu | |
mkdir "$HOME/.ssh" | |
echo "${{ secrets.DEPLOY_KEY }}" > "$HOME/.ssh/doka_deploy" | |
chmod 600 "$HOME/.ssh/doka_deploy" | |
- name: Сборка и публикация сайта | |
id: build-preview | |
continue-on-error: true | |
run: | | |
cp .env.example .env | |
npm run preview | |
ssh -i $HOME/.ssh/doka_deploy -o StrictHostKeyChecking=no deploy@dev.doka.guide mkdir -p /web/sites/dev.doka.guide/platform/${{ github.event.pull_request.number }} | |
cd dist && rsync -e "ssh -i $HOME/.ssh/doka_deploy -o StrictHostKeyChecking=no" --archive --progress --compress --delete . deploy@dev.doka.guide:/web/sites/dev.doka.guide/platform/${{ github.event.pull_request.number }} | |
echo "Ссылка на превью — ${{ env.DEPLOY_DOMAIN }}" | |
echo -e "${{ steps.links.outputs.list }}" | |
- name: Сообщение о неудаче публикации превью | |
uses: hasura/comment-progress@v2.1.0 | |
if: failure() | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.pull_request.number }} | |
id: preview-${{ github.event.pull_request.number }} | |
message: "Превью контента из ${{ github.event.after }} не опубликовано. Ошибка сборки или публикации. [Подробнее](https://github.com/${{ github.repository }}/runs/${{ steps.check.outputs.check_id }}?check_suite_focus=true)" | |
fail: true | |
recreate: true | |
- name: Сообщение об успехе публикации превью | |
uses: hasura/comment-progress@v2.1.0 | |
if: success() | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.pull_request.number }} | |
id: preview-${{ github.event.pull_request.number }} | |
message: '<a href="${{ env.DEPLOY_DOMAIN }}">Превью контента</a> из ${{ github.event.after }} опубликовано.' | |
recreate: true |