Last active
February 15, 2024 17:19
-
-
Save cheshire137/3b8ee82e4cf9f31eb774b9154a917d17 to your computer and use it in GitHub Desktop.
Script to trigger a GitHub Actions workflow for each pull request in a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for item in $(gh pr list --assignee cheshire137 --repo someUser/someRepo --state open --json headRefName,number,headRepository,headRepositoryOwner --search "updated:>=$(date -Idate)" --jq ".[]"); do | |
number=$(jq --raw-output '.number' <<< "$item") | |
headRefName=$(jq --raw-output '.headRefName' <<< "$item") | |
repoName=$(jq --raw-output '.headRepository.name' <<< "$item") | |
repoOwner=$(jq --raw-output '.headRepositoryOwner.login' <<< "$item") | |
echo "$repoOwner/$repoName#$number $headRefName" | |
read -r -p "Run workflow? [Y/n] " response | |
response=${response,,} # tolower | |
if [[ $response =~ ^(y| ) ]] || [[ -z $response ]]; then | |
gh workflow run someWorkflow.yml --ref $headRefName --repo $repoOwner/$repoName --field pullRequestNumber=$number | |
else | |
echo "Skipping" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment