|
5 | 5 | branches: |
6 | 6 | - 'claude/**' |
7 | 7 |
|
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
8 | 11 | jobs: |
9 | 12 | test-lucee7-mysql: |
10 | 13 | name: Lucee 7 + MySQL |
@@ -115,6 +118,86 @@ jobs: |
115 | 118 | echo "Result file not found" |
116 | 119 | fi |
117 | 120 |
|
| 121 | + - name: Commit workflow results to branch |
| 122 | + if: always() |
| 123 | + run: | |
| 124 | + RESULTS_DIR=".github/workflow-results" |
| 125 | + RESULTS_FILE="${RESULTS_DIR}/test-lucee7-mysql.md" |
| 126 | + mkdir -p "$RESULTS_DIR" |
| 127 | +
|
| 128 | + # Determine status |
| 129 | + if [ "${{ steps.run-tests.outcome }}" = "success" ]; then |
| 130 | + STATUS="PASSED" |
| 131 | + else |
| 132 | + STATUS="FAILED" |
| 133 | + fi |
| 134 | +
|
| 135 | + # Build the results file |
| 136 | + echo "# Workflow Results: Test Lucee 7 + MySQL" > "$RESULTS_FILE" |
| 137 | +
|
| 138 | + { |
| 139 | + echo "" |
| 140 | + echo "**Status:** ${STATUS}" |
| 141 | + echo "**Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" |
| 142 | + echo "**Commit:** ${{ github.sha }}" |
| 143 | + echo "**Branch:** ${{ github.ref_name }}" |
| 144 | + echo "**Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" |
| 145 | + echo "" |
| 146 | + echo "## Test Results" |
| 147 | + echo "" |
| 148 | + if [ -f "/tmp/lucee7-mysql-result.txt" ]; then |
| 149 | + CONTENT=$(cat /tmp/lucee7-mysql-result.txt) |
| 150 | + # Try to detect if content is JSON and format accordingly |
| 151 | + if echo "$CONTENT" | python3 -m json.tool > /dev/null 2>&1; then |
| 152 | + echo '```json' |
| 153 | + echo "$CONTENT" | python3 -m json.tool 2>/dev/null || echo "$CONTENT" |
| 154 | + echo '```' |
| 155 | + else |
| 156 | + echo '```' |
| 157 | + echo "$CONTENT" |
| 158 | + echo '```' |
| 159 | + fi |
| 160 | + else |
| 161 | + echo "No test result file was generated." |
| 162 | + fi |
| 163 | + } >> "$RESULTS_FILE" |
| 164 | +
|
| 165 | + # Add debug info on failure |
| 166 | + if [ "$STATUS" = "FAILED" ]; then |
| 167 | + { |
| 168 | + echo "" |
| 169 | + echo "## Debug Information" |
| 170 | + echo "" |
| 171 | + echo "### Docker Container Status" |
| 172 | + echo '```' |
| 173 | + docker ps -a 2>&1 || echo "Could not get container status" |
| 174 | + echo '```' |
| 175 | + echo "" |
| 176 | + echo "### Lucee 7 Container Logs (last 50 lines)" |
| 177 | + echo '```' |
| 178 | + docker logs $(docker ps -aq -f "name=lucee7") 2>&1 | tail -50 || echo "Could not get logs" |
| 179 | + echo '```' |
| 180 | + echo "" |
| 181 | + echo "### MySQL Container Logs (last 50 lines)" |
| 182 | + echo '```' |
| 183 | + docker logs $(docker ps -aq -f "name=mysql") 2>&1 | tail -50 || echo "Could not get logs" |
| 184 | + echo '```' |
| 185 | + } >> "$RESULTS_FILE" |
| 186 | + fi |
| 187 | +
|
| 188 | + # Commit and push results back to the branch |
| 189 | + git config user.name "github-actions[bot]" |
| 190 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 191 | + git add "$RESULTS_FILE" |
| 192 | +
|
| 193 | + # Only commit if there are changes |
| 194 | + if git diff --cached --quiet; then |
| 195 | + echo "No changes to commit" |
| 196 | + else |
| 197 | + git commit -m "ci: add workflow results for test-lucee7-mysql [skip ci]" |
| 198 | + git push origin HEAD:${{ github.ref_name }} |
| 199 | + fi |
| 200 | +
|
118 | 201 | - name: Upload Test Results |
119 | 202 | if: always() |
120 | 203 | uses: actions/upload-artifact@v4 |
|
0 commit comments