@@ -102,11 +102,6 @@ runs:
102102
103103 else
104104
105- cd ${GITHUB_WORKSPACE//\\//}
106-
107- echo -e "\n$hr\nConfig\n$hr"
108- cat _config.yml
109-
110105 echo -e "\n$hr\nSource Pages\n$hr"
111106 rm -rf _user && ls -al .
112107
@@ -134,9 +129,6 @@ runs:
134129 echo "Original : $LATEST_COMMIT"
135130 echo "Processed : $MESSAGE"
136131
137- # Commit and push changes
138- git add . && git commit --allow-empty -m "$MESSAGE" && git push
139-
140132 echo -e "\n$hr\nFinal Status\n$hr"
141133 # Fetch all branches
142134 git fetch --all
@@ -174,27 +166,48 @@ runs:
174166 echo "Created v0 branch and set it as default"
175167 fi
176168
177- if [[ "$TARGET_REPOSITORY" != *"eq19/"* ]]; then
178- # Unpublish existing GitHub Pages
179- curl -s -X DELETE \
180- -H "Authorization : token $GH_TOKEN" \
181- -H "Accept : application/vnd.github.v3+json" \
182- https://api.github.com/repos/$TARGET_REPOSITORY/pages > /dev/null
183-
184- # Disable GitHub Pages
185- curl -s -X PATCH \
186- -H "Authorization : token $GH_TOKEN" \
187- -H "Accept : application/vnd.github.v3+json" \
188- https://api.github.com/repos/$TARGET_REPOSITORY/pages \
189- -d '{"build_type":"legacy","source":null}' > /dev/null
190-
191- # Trigger a dispaches action
169+ AUTH="Authorization : Bearer $GH_TOKEN"
170+ VERSION="X-GitHub-Api-Version : 2022-11-28"
171+ ACCEPT="Accept : application/vnd.github+json"
172+ RESPONSE=$(curl -s -L -H "$AUTH" -H "$VERSION" -H "$ACCEPT" "https://api.github.com/repos/$TARGET_REPOSITORY/actions/runners")
173+ STATUS=$(echo "$RESPONSE" | jq -r --arg NAME "$RUNNER_TITLE" '.runners[] | select(.name == $NAME).status')
174+
175+ if [[ "$STATUS" != "online" ]]; then
176+
192177 curl -s -X POST \
193178 -H "Authorization : token $GH_TOKEN" \
194179 -H "Accept : application/vnd.github.v3+json" \
195- https://api.github.com/repos/$TARGET_REPOSITORY /dispatches \
196- -d '{"event_type" : " trigger_action " , "client_payload": {"env ": "prod", "version": "1.0 "}}'
197- echo -e "\nDispatched to https://github.com/${{ env.TARGET_REPOSITORY }}/actions"
198- fi
180+ " https://api.github.com/repos/$GITHUB_REPOSITORY /dispatches" \
181+ -d '{"event_type" : " retry_workflow " , "client_payload": {"original_run_id ": "$GITHUB_RUN_ID "}}'
182+ echo -e "\nDispatched to https://github.com/${{ env.GITHUB_REPOSITORY }}/actions"
183+ exit 1
199184
185+ else
186+
187+ # Commit and push changes
188+ git add . && git commit --allow-empty -m "$MESSAGE" && git push
189+
190+ if [[ "$TARGET_REPOSITORY" != *"eq19/"* ]]; then
191+ # Unpublish existing GitHub Pages
192+ curl -s -X DELETE \
193+ -H "Authorization : token $GH_TOKEN" \
194+ -H "Accept : application/vnd.github.v3+json" \
195+ https://api.github.com/repos/$TARGET_REPOSITORY/pages > /dev/null
196+
197+ # Disable GitHub Pages
198+ curl -s -X PATCH \
199+ -H "Authorization : token $GH_TOKEN" \
200+ -H "Accept : application/vnd.github.v3+json" \
201+ https://api.github.com/repos/$TARGET_REPOSITORY/pages \
202+ -d '{"build_type":"legacy","source":null}' > /dev/null
203+
204+ # Trigger a dispaches action
205+ curl -s -X POST \
206+ -H "Authorization : token $GH_TOKEN" \
207+ -H "Accept : application/vnd.github.v3+json" \
208+ " https://api.github.com/repos/$TARGET_REPOSITORY/dispatches" \
209+ -d '{"event_type" : " trigger_action" , "client_payload": {"env": "prod", "version": "1.0"}}'
210+ echo -e "\nDispatched to https://github.com/${{ env.TARGET_REPOSITORY }}/actions"
211+ fi
212+ fi
200213 fi
0 commit comments