tenseleyflow/shithub / 1872d5d

Browse files

Retry deploy mirror push

Authored by espadonne
SHA
1872d5d61a90078da84c01eb9c9bf2043d3e0465
Parents
ecd35ed
Tree
bd58509

1 changed file

StatusFile+-
M .github/workflows/deploy.yml 30 4
.github/workflows/deploy.ymlmodified
@@ -100,13 +100,39 @@ jobs:
100100
       # diverges from origin/trunk, the push fails non-fast-forward
101101
       # and a human reconciles. We never want a runner to silently
102102
       # overwrite a human edit on the mirror.
103
+      #
104
+      # The app may still be coming back through Caddy immediately
105
+      # after the systemd restart. Wait for the public HTTP surface
106
+      # and retry the mirror push so a transient 502 does not mark a
107
+      # successful deploy as failed. Persistent auth, divergence, or
108
+      # server errors still fail the job.
103109
       - name: Mirror to shithub.sh
104110
         if: success()
105111
         env:
106112
           SHITHUB_PUSH_USER: ${{ secrets.SHITHUB_PUSH_USER }}
107113
           SHITHUB_PUSH_PAT:  ${{ secrets.SHITHUB_PUSH_PAT }}
108114
         run: |
109
-          git -c "credential.helper=!f() { echo username=$SHITHUB_PUSH_USER; echo password=$SHITHUB_PUSH_PAT; }; f" \
110
-              push \
111
-              https://shithub.sh/tenseleyflow/shithub.git \
112
-              HEAD:trunk
115
+          curl --fail --silent --show-error \
116
+            --retry 6 --retry-delay 5 --retry-all-errors \
117
+            https://shithub.sh/ \
118
+            --output /dev/null
119
+
120
+          mirror_push() {
121
+            git -c "credential.helper=!f() { echo username=$SHITHUB_PUSH_USER; echo password=$SHITHUB_PUSH_PAT; }; f" \
122
+                push \
123
+                https://shithub.sh/tenseleyflow/shithub.git \
124
+                HEAD:trunk
125
+          }
126
+
127
+          status=0
128
+          for attempt in 1 2 3 4 5; do
129
+            if mirror_push; then
130
+              exit 0
131
+            fi
132
+            status=$?
133
+            if [ "$attempt" -eq 5 ]; then
134
+              break
135
+            fi
136
+            sleep "$((attempt * 10))"
137
+          done
138
+          exit "$status"