Skip to content

Commit 8462681

Browse files
committed
fix: 자동배포 스크립트 에러 대응
- cat 명령에서 $() 내부의 값이 bash에서 자동 실행되는 문제 대응 (백슬래시 붙이자~) - script output grouping
1 parent 36d8183 commit 8462681

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,46 @@ jobs:
1616
steps:
1717
- name: Make deploy script
1818
run: |
19-
cat << EOF > $DEPLOY_SCRIPT
19+
cat << EOF > $DEPLOY_SCRIPT
2020
echo "=== pull master branch ==="
2121
cd ${{ secrets.SSH_WORKING_DIRECTORY }}/src
2222
git checkout master
2323
git fetch origin master
24-
BE_DIFF=$(git diff HEAD..origin/master --name-only -- src/backend | wc -l)
25-
FE_DIFF=$(git diff HEAD..origin/master --name-only -- src/frontend | wc -l)
24+
BE_DIFF=\$(git diff HEAD..origin/master --name-only -- ./backend | wc -l)
25+
FE_DIFF=\$(git diff HEAD..origin/master --name-only -- ./frontend | wc -l)
2626
git pull origin master
27-
28-
if [ $BE_DIFF -ne 0 ] ; then
29-
echo "=== build backend ==="
27+
28+
echo "::group::Build & run backend application"
29+
if [ \$BE_DIFF -ne 0 ] ; then
30+
echo -e "\n=== build backend ==="
3031
cd backend
3132
npm ci || exit 1
3233
npm run build || exit 1
33-
echo "=== restart backend server ==="
34+
echo -e "\n=== restart backend server ==="
3435
forever stopall
3536
forever start ./dist/app.js
3637
cd ..
38+
else
39+
echo "- Backend code not changed; step skipped."
3740
fi
38-
39-
if [ $FE_DIFF -ne 0 ] ; then
40-
echo "=== build frontend ==="
41+
echo "::endgroup::"
42+
43+
echo "::group::Build & run frontend application"
44+
if [ \$FE_DIFF -ne 0 ] ; then
45+
echo -e "\n=== build frontend ==="
4146
cd frontend
4247
npm ci || exit 1
4348
npm run build || exit 1
44-
echo "=== update nginx serve files ==="
49+
echo -e "\n=== update nginx serve files ==="
4550
# rm -rf ${{ secrets.NGINX_DIRECTORY }}
4651
sudo cp ./dist/* ${{ secrets.NGINX_DIRECTORY }}
4752
cd ..
53+
else
54+
echo "- Frontend code not changed; step skipped."
4855
fi
56+
echo "::endgroup::"
4957
50-
echo "=== All done🚀 ==="
58+
echo -e "\n=== All done🚀 ==="
5159
EOF
5260
5361
- name: Setting ssh agent and key

0 commit comments

Comments
 (0)