chore(ci): upgrade action to fix dependabot alert #6
Workflow file for this run
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
name: check-status | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- dev | |
- "[2-9][0-9].[0-9][0-9].x" | |
jobs: | |
check-status: | |
runs-on: [self-hosted, centreon-ubuntu-22.04] | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Check other workflow statuses and display token usage | |
run: | | |
display_token_usage () { | |
echo "current token usage:" | |
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .rate | |
echo "" | |
} | |
display_token_usage | |
sleep 30s | |
ITERATIONS=1 | |
while [[ $ITERATIONS -le 60 ]]; do | |
CHECK_SUITES=$(gh api -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-suites | jq '. | .check_suites[] | select(.app.slug == "github-actions")' | jq -r '.conclusion // "pending"') || true | |
if [ $(echo $CHECK_SUITES | grep -o -i 'pending' | wc -l) -eq 0 ]; then | |
echo "Cannot get pull request check status" | |
exit 1 | |
fi | |
if [ $(echo $CHECK_SUITES | wc -w) -eq 1 ]; then | |
echo "this job is the only triggered one" | |
exit 0 | |
fi | |
if [ $(echo $CHECK_SUITES | grep -o -i 'failure' | wc -l) -gt 0 ]; then | |
echo "some jobs have failed" | |
exit 1 | |
fi | |
# only remaining pending job should be check-status itself | |
if [ $(echo $CHECK_SUITES | grep -o -i 'pending' | wc -l) -eq 1 ]; then | |
echo "all jobs have passed" | |
exit 0 | |
fi | |
if [ $ITERATIONS -lt 60 ]; then | |
echo "some jobs are still in progress, next try in 60 seconds... (tries: $ITERATIONS/60)" | |
sleep 30s | |
display_token_usage | |
sleep 30s | |
display_token_usage | |
fi | |
ITERATIONS=$((ITERATIONS+1)) | |
done | |
echo "Timeout: some jobs are still in progress" | |
exit 1 | |
shell: bash | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |