|
9 | 9 | jobs: |
10 | 10 | laravel-tests: |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + |
12 | 13 | services: |
13 | 14 | mysql: |
14 | 15 | image: mysql:8.0 |
|
24 | 25 | --health-interval 10s |
25 | 26 | --health-timeout 5s |
26 | 27 | --health-retries 3 |
| 28 | + timeout-minutes: 1 |
27 | 29 |
|
28 | 30 | steps: |
29 | 31 | - uses: actions/checkout@v3 |
|
38 | 40 | - name: Install Dependencies |
39 | 41 | run: | |
40 | 42 | composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist |
41 | | - cp .env.example .env |
| 43 | + cp env.txt .env |
42 | 44 | php artisan key:generate |
43 | 45 |
|
44 | 46 | - name: Directory Permissions |
@@ -79,63 +81,41 @@ jobs: |
79 | 81 | run: | |
80 | 82 | php artisan migrate:fresh --seed --force |
81 | 83 |
|
82 | | - - name: Execute Tests (Unit and Feature tests) via PHPUnit |
| 84 | + - name: Execute Tests |
83 | 85 | env: |
84 | 86 | DB_CONNECTION: mysql |
85 | 87 | DB_DATABASE: test_db |
86 | 88 | DB_USERNAME: test_user |
87 | 89 | DB_PASSWORD: password |
88 | 90 | 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 |
95 | 103 |
|
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 |
109 | 117 |
|
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