|
77 | 77 | echo "has_changes=true" >> $GITHUB_OUTPUT |
78 | 78 | echo "commit_branch=${COMMIT_BRANCH}" >> $GITHUB_OUTPUT |
79 | 79 | |
80 | | - # Push the new branch |
81 | | - git push origin "$COMMIT_BRANCH" |
| 80 | + # Push the new branch with error handling |
| 81 | + echo "Försöker pusha branch '${COMMIT_BRANCH}' till origin..." |
| 82 | + |
| 83 | + if git push origin "$COMMIT_BRANCH" 2>&1; then |
| 84 | + echo "✅ Git push lyckades för branch '${COMMIT_BRANCH}'" |
| 85 | + echo "push_success=true" >> $GITHUB_OUTPUT |
| 86 | + echo "push_error=" >> $GITHUB_OUTPUT |
| 87 | + else |
| 88 | + PUSH_EXIT_CODE=$? |
| 89 | + PUSH_ERROR="Git push misslyckades med exit code: ${PUSH_EXIT_CODE}" |
| 90 | + echo "❌ ${PUSH_ERROR}" |
| 91 | + echo "push_success=false" >> $GITHUB_OUTPUT |
| 92 | + echo "push_error=${PUSH_ERROR}" >> $GITHUB_OUTPUT |
| 93 | + |
| 94 | + # Logga mer detaljerad information för debugging |
| 95 | + echo "Git status:" |
| 96 | + git status |
| 97 | + echo "Git remote info:" |
| 98 | + git remote -v |
| 99 | + echo "Git log (senaste commit):" |
| 100 | + git log --oneline -1 |
| 101 | + |
| 102 | + # Switch back to original branch even if push failed |
| 103 | + git checkout "$CURRENT_BRANCH" |
| 104 | + |
| 105 | + # Fail the job if push failed |
| 106 | + echo "::error::Git push misslyckades: ${PUSH_ERROR}" |
| 107 | + exit 1 |
| 108 | + fi |
82 | 109 | |
83 | 110 | # Switch back to original branch |
84 | 111 | git checkout "$CURRENT_BRANCH" |
|
87 | 114 | fi |
88 | 115 |
|
89 | 116 | - name: Trigger HTML export workflow |
90 | | - if: steps.commit_changes.outputs.has_changes == 'true' |
| 117 | + if: steps.commit_changes.outputs.has_changes == 'true' && steps.commit_changes.outputs.push_success == 'true' |
91 | 118 | uses: actions/github-script@v6 |
92 | 119 | with: |
93 | 120 | github-token: ${{ secrets.GITHUB_TOKEN }} |
|
98 | 125 | workflow_id: 'html-export-workflow.yml', |
99 | 126 | ref: context.ref |
100 | 127 | }) |
| 128 | +
|
| 129 | + - name: Report push failure |
| 130 | + if: steps.commit_changes.outputs.has_changes == 'true' && steps.commit_changes.outputs.push_success == 'false' |
| 131 | + run: | |
| 132 | + echo "::warning::Git push misslyckades: ${{ steps.commit_changes.outputs.push_error }}" |
| 133 | + echo "HTML export workflow kommer inte att triggas på grund av push-fel." |
0 commit comments