Skip to content

Commit 19ddf23

Browse files
author
您的名字
committed
更新 GitHub Actions 工作流程和 composer.lock
1 parent 44d0c4b commit 19ddf23

2 files changed

Lines changed: 410 additions & 416 deletions

File tree

.github/workflows/laravel.yml

Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
laravel-tests:
1111
runs-on: ubuntu-latest
12+
1213
services:
1314
mysql:
1415
image: mysql:8.0
@@ -24,6 +25,7 @@ jobs:
2425
--health-interval 10s
2526
--health-timeout 5s
2627
--health-retries 3
28+
timeout-minutes: 1
2729

2830
steps:
2931
- uses: actions/checkout@v3
@@ -38,7 +40,7 @@ jobs:
3840
- name: Install Dependencies
3941
run: |
4042
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
41-
cp .env.example .env
43+
cp env.txt .env
4244
php artisan key:generate
4345
4446
- name: Directory Permissions
@@ -79,63 +81,41 @@ jobs:
7981
run: |
8082
php artisan migrate:fresh --seed --force
8183
82-
- name: Execute Tests (Unit and Feature tests) via PHPUnit
84+
- name: Execute Tests
8385
env:
8486
DB_CONNECTION: mysql
8587
DB_DATABASE: test_db
8688
DB_USERNAME: test_user
8789
DB_PASSWORD: password
8890
run: |
89-
php artisan test
90-
91-
deploy:
92-
needs: laravel-tests
93-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
94-
runs-on: ubuntu-latest
91+
# 先執行測試,如果沒有測試則跳過
92+
if [ -d "tests" ]; then
93+
php artisan test
94+
else
95+
echo "No tests found, skipping..."
96+
fi
97+
98+
# 部署步驟已暫時註解,待測試通過後再啟用
99+
# deploy:
100+
# needs: laravel-tests
101+
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
102+
# runs-on: ubuntu-latest
95103

96-
steps:
97-
- name: Checkout code
98-
uses: actions/checkout@v3
99-
100-
- name: Setup PHP
101-
uses: shivammathur/setup-php@v2
102-
with:
103-
php-version: '8.1'
104-
extensions: dom, curl, libxml, mbstring, xml, zip, ctype, fileinfo, json, pdo, tokenizer, xmlwriter, gd, mysql, pdo_mysql
105-
106-
- name: Install Dependencies
107-
run: |
108-
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
104+
# steps:
105+
# - name: Checkout code
106+
# uses: actions/checkout@v3
107+
108+
# - name: Setup PHP
109+
# uses: shivammathur/setup-php@v2
110+
# with:
111+
# php-version: '8.1'
112+
# extensions: dom, curl, libxml, mbstring, xml, zip, ctype, fileinfo, json, pdo, tokenizer, xmlwriter, gd, mysql, pdo_mysql
113+
114+
# - name: Install Dependencies
115+
# run: |
116+
# composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
109117

110-
- name: Build assets (if using Laravel Mix or Vite)
111-
run: |
112-
npm ci
113-
npm run build --if-present
114-
115-
- name: Upload to server
116-
uses: appleboy/scp-action@master
117-
with:
118-
host: ${{ secrets.SSH_HOST }}
119-
username: ${{ secrets.SSH_USERNAME }}
120-
key: ${{ secrets.SSH_PRIVATE_KEY }}
121-
source: "*"
122-
target: ${{ secrets.DEPLOY_PATH }}
123-
124-
- name: Execute remote commands
125-
uses: appleboy/ssh-action@master
126-
with:
127-
host: ${{ secrets.SSH_HOST }}
128-
username: ${{ secrets.SSH_USERNAME }}
129-
key: ${{ secrets.SSH_PRIVATE_KEY }}
130-
script: |
131-
cd ${{ secrets.DEPLOY_PATH }}
132-
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
133-
php artisan migrate --force
134-
php artisan config:cache
135-
php artisan route:cache
136-
php artisan view:cache
137-
php artisan storage:link
138-
php artisan optimize
139-
# 重新啟動 PHP-FPM 或您的 Web 伺服器
140-
# sudo systemctl restart php8.1-fpm
141-
# sudo systemctl restart nginx
118+
# - name: Build assets
119+
# run: |
120+
# npm ci
121+
# npm run build --if-present

0 commit comments

Comments
 (0)