File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Keep Workflows alive
2-
32on :
43 workflow_dispatch :
54 schedule :
@@ -15,16 +14,28 @@ jobs:
1514 permissions :
1615 actions : write
1716 steps :
18- - uses : actions/checkout@v6
19- - name : Re-enable workflow
17+ - name : Re-enable all active workflows
2018 env :
21- GITHUB_TOKEN : ${{ inputs .GITHUB_TOKEN || github.token }}
22- shell : sh
19+ GITHUB_TOKEN : ${{ secrets .GITHUB_TOKEN }}
20+ shell : bash
2321 run : |
24- case "${GITHUB_WORKFLOW_REF:?}" in
25- "${GITHUB_REPOSITORY:?}"/.github/workflows/*.y*ml@*) ;;
26- *) false ;;
27- esac
28- workflow="${GITHUB_WORKFLOW_REF%%@*}"
29- workflow="${workflow#${GITHUB_REPOSITORY}/.github/workflows/}"
30- gh api -X PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/${workflow}/enable"
22+ set -euo pipefail
23+
24+ echo "Fetching active workflows for ${GITHUB_REPOSITORY}..."
25+
26+ workflow_ids=$(gh api --paginate \
27+ "repos/${GITHUB_REPOSITORY}/actions/workflows" \
28+ --jq '.workflows[] | select(.state=="active") | .id')
29+
30+ if [ -z "$workflow_ids" ]; then
31+ echo "No active workflows found."
32+ exit 0
33+ fi
34+
35+ echo "$workflow_ids" | while read -r id; do
36+ name=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/${id}" --jq '.name')
37+ echo "Re-enabling workflow: ${name} (ID: ${id})"
38+ gh api -X PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/${id}/enable"
39+ done
40+
41+ echo "Done."
You can’t perform that action at this time.
0 commit comments