Skip to content

ДобавляСт Π΄ΠΎΠΊΡƒ для ΠΌΠ΅Ρ‚ΠΎΠ΄Π° массива toSpliced() #6870

ДобавляСт Π΄ΠΎΠΊΡƒ для ΠΌΠ΅Ρ‚ΠΎΠ΄Π° массива toSpliced()

ДобавляСт Π΄ΠΎΠΊΡƒ для ΠΌΠ΅Ρ‚ΠΎΠ΄Π° массива toSpliced() #6870

Workflow file for this run

name: PR Preview
on:
pull_request_target:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.files.outputs.all }}
steps:
- name: Π’Ρ‹Π±ΠΎΡ€ΠΊΠ° Ρ„Π°ΠΉΠ»ΠΎΠ² для формирования списка
id: files
run: |
pr_files=$(echo $(curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files))
list=$(echo $pr_files | grep -o '"filename": "[^"]*' | cut -d'"' -f4)
mdReplaced=${list//md/html}
returnReplaced=${list//$"\n"/ }
echo "::set-output name=all::$returnReplaced"
echo $returnReplaced
pr-preview:
runs-on: ubuntu-latest
needs:
- prepare
env:
DEPLOY_DOMAIN: https://content-${{ github.event.pull_request.number }}.dev.doka.guide
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PATH_TO_CONTENT: ./content
steps:
- name: Π—Π°Π³Ρ€ΡƒΠ·ΠΊΠ° platform
uses: actions/checkout@v4
with:
repository: doka-guide/platform
- name: Π—Π°Π³Ρ€ΡƒΠ·ΠΊΠ° ΠΊΠΎΠ½Ρ‚Π΅Π½Ρ‚Π°
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: content
- name: Π—Π°Π³Ρ€ΡƒΠ·ΠΊΠ° кСша
uses: actions/checkout@v4
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
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 -r ./cache/.cache ./
- name: Π‘ΠΎΠΎΠ±Ρ‰Π΅Π½ΠΈΠ΅ ΠΎ Π½Π°Ρ‡Π°Π»Π΅ ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΠΈ ΠΏΡ€Π΅Π²ΡŒΡŽ
uses: hasura/[email protected]
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: Π€ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ списка Ρ„Π°ΠΉΠ»ΠΎΠ²
id: links
run: |
file_list=""
for f in ${{ needs.prepare.outputs.files }}; do
if [[ $changed_file =~ ".html" ]]; then
file_list=$(echo -e "${file_list}<li><a href="${{ env.DEPLOY_DOMAIN }}/${f}">${f}</a></li>")
fi
done
if ! [[ $file_list == "" ]]; then
file_list=$(echo -e "<br><p>Бписок ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… ΠΌΠ°Ρ‚Π΅Ρ€ΠΈΠ°Π»ΠΎΠ²:<ul>${file_list}</ul><p>")
fi
echo ::set-output name=list::$(echo -e "${file_list}")
- 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 [email protected] mkdir -p /web/sites/dev.doka.guide/content/${{ github.event.pull_request.number }}
cd dist && rsync -e "ssh -i $HOME/.ssh/doka_deploy -o StrictHostKeyChecking=no" --archive --progress --compress --delete . [email protected]:/web/sites/dev.doka.guide/content/${{ github.event.pull_request.number }}
echo "Бсылка Π½Π° ΠΏΡ€Π΅Π²ΡŒΡŽ β€” ${{ env.DEPLOY_DOMAIN }}"
echo -e "${{ steps.links.outputs.list }}"
- name: Π‘ΠΎΠΎΠ±Ρ‰Π΅Π½ΠΈΠ΅ ΠΎ Π½Π΅ΡƒΠ΄Π°Ρ‡Π΅ ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΠΈ ΠΏΡ€Π΅Π²ΡŒΡŽ
uses: hasura/[email protected]
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/[email protected]
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: '<details><summary><a href="${{ env.DEPLOY_DOMAIN }}">ΠŸΡ€Π΅Π²ΡŒΡŽ ΠΊΠΎΠ½Ρ‚Π΅Π½Ρ‚Π°</a> ΠΈΠ· ${{ github.event.after }} ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½ΠΎ.</summary>${{ steps.links.outputs.list }}</details>'
recreate: true