ΠΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π΄ΠΎΠΊΡ Π΄Π»Ρ ΠΌΠ΅ΡΠΎΠ΄Π° ΠΌΠ°ΡΡΠΈΠ²Π° toSpliced() #6870
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: | |
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 |