# By User
actor:chriswblake
# By Repo
repo:my-org/our-repo
steps:
- name: Show context
run: echo "${{ toJSON(github) }}"- name: Show base branch
run: echo "${{ github.event.base_ref }}"-
Follow the usual process for adding a self-hosted runner to an organization.
- Navigate to the organization.
- Select Settings tab.
- In left navigation, select Actions and Runners
- Select green New runner button.
- Follow prompts.
-
Open the CRON file.
sudo vim /etc/crontab
-
Add an entry at the end to restart the runner after reboot.
- replace
ubuntuwith the username the runner was installed on. - adjust the path if the default was not used.
@reboot ubuntu ~/actions-runner/run.sh
- replace
-
Confirm the file contents
cat /etc/crontab
-
Reboot the machine
sudo reboot -
Confirm the runner is idle on GitHub.
Note: Requires GitHub CLI installed.
# Select the target repo
REPO="owner/repo-name"
# Get all workflow run IDs and store in array
WORKFLOW_RUN_IDS=()
while IFS= read -r id; do
WORKFLOW_RUN_IDS+=("$id")
done < <(
gh api \
--paginate \
"repos/$REPO/actions/runs" \
--jq '.workflow_runs[].id'
)
WORKFLOW_RUN_COUNT=${#WORKFLOW_RUN_IDS[@]}
# Loop through each and send API call to delete it
echo "Deleting $WORKFLOW_RUN_COUNT workflow runs."
COUNTER=0
for id in "${WORKFLOW_RUN_IDS[@]}"; do
COUNTER=$((COUNTER + 1))
echo "$COUNTER/$WORKFLOW_RUN_COUNT - Deleting workflow run with ID: $id"
gh api -X DELETE "repos/$REPO/actions/runs/$id?cleanup=true"
done