@@ -14,22 +14,6 @@ git config --global --add safe.directory "${GITHUB_WORKSPACE}"
1414git config --global credential.helper store
1515echo " https://${GITHUB_ACTOR} :${GH_TOKEN} @github.com" > ~ /.git-credentials
1616
17- # Get current repo name in owner/repo format
18- CURRENT_REPO=$( gh repo view --json nameWithOwner -q ' .nameWithOwner' )
19-
20- # Get list of all repositories (user and org)
21- ALL_REPOS=$( gh repo list --limit 1000 --json nameWithOwner -q ' .[].nameWithOwner' )
22-
23- # Loop through all repos and cancel runs except current one
24- for repo in $ALL_REPOS ; do
25- if [ " $repo " != " $CURRENT_REPO " ]; then
26- echo " Canceling runs in $repo "
27- gh api -X POST " /repos/$repo /actions/runs/cancel" || echo " Failed to cancel runs in $repo "
28- else
29- echo " Skipping current repo: $repo "
30- fi
31- done
32-
3317export RERUN_RUNNER=$( curl -s -H " Authorization: token $GH_TOKEN " -H " Accept: application/vnd.github.v3+json" \
3418 " https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/variables/RERUN_RUNNER" | jq -r ' .value' )
3519export TARGET_REPOSITORY=$( curl -s -H " Authorization: token $GH_TOKEN " -H " Accept: application/vnd.github.v3+json" \
@@ -70,7 +54,21 @@ if [[ -z ${PASS} ]] || [[ "${PASS}" == "true" ]]; then
7054 echo -e " \n$hr \nCONFIG\n$hr "
7155 mv -f /home/runner/work/_actions/eq19/eq19/v2/.github/templates/jekyll_config.yml $RUNNER_TEMP /_config.yml
7256 export PATH=/home/runner/work/_actions/eq19/eq19/v2/.github/entrypoint:$PATH && artifact.sh
73-
57+
58+ # Loop through all repos and cancel runs except current one
59+ # ALL_REPOS=""
60+ # ORGS=$(gh api user/orgs --jq '.[].login')
61+ # CURRENT_REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
62+ # ALL_REPOS+=$(gh repo list --limit 1000 --json nameWithOwner -q '.[].nameWithOwner')
63+ # for org in $ORGS; do ALL_REPOS+=$(gh repo list $org --limit 1000 --json nameWithOwner -q '.[].nameWithOwner'); done
64+ # for REPO in $ALL_REPOS; do
65+ # if [ "$REPO" != "$CURRENT_REPO" ]; then
66+ # RUNS=$(gh api "repos/$REPO/actions/runs?status=in_progress" --jq '.workflow_runs[].id')
67+ # RUNS+=" $(gh api "repos/$REPO/actions/runs?status=queued" --jq '.workflow_runs[].id')"
68+ # for RUN_ID in $RUNS; do gh api -X POST "repos/$REPO/actions/runs/$RUN_ID/force-cancel"; done
69+ # fi
70+ # done
71+
7472 PARAMS_JSON=$( curl -s -H " Authorization: token $GH_TOKEN " -H " Accept: application/vnd.github.v3+json" \
7573 " https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/variables/PARAMS_JSON" | jq -r ' .value' )
7674 echo " ${PARAMS_JSON} " | jq ' .' > $1 /user_data/strategies/fibbo.json
@@ -112,6 +110,11 @@ if [[ "${JOBS_ID}" == "1" ]]; then
112110 cd $1 && javac -d user_data/ft_client/test_client javaCode/Main.java
113111 cd $GITHUB_WORKSPACE && rm -rf user_data && mv -f $1 /user_data . && ls -al .
114112
113+ # Fetch SHA, encode new content, and update in one step
114+ gh api --method PUT /repos/${TARGET_REPOSITORY} /contents/.github/workflows/main.yml \
115+ -f sha=" $( gh api /repos/${TARGET_REPOSITORY} /contents/.github/workflows/main.yml --jq ' .sha' ) " \
116+ -f message=" Update file" -f content=" $( base64 -w0 .github/workflows/main.yml) " > /dev/null
117+
115118 fi
116119
117120elif [[ " ${JOBS_ID} " == " 2" ]]; then
0 commit comments