Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/scripts/check_workflow_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Script to check the status of the latest workflow run for a specified event type

#!/bin/bash

GITHUB_TOKEN=$1
REPO=$2
EVENT_TYPE=$3
MAX_RETRIES=5
POLL_INTERVAL=30
RETRY_COUNT=0
WORKFLOWS_API_URL="https://api.github.com/repos/${REPO}/actions/runs?event=${EVENT_TYPE}"
LATEST_WORKFLOW_ID=""

echo "Checking workflow status for ${REPO}..."

# Get the latest workflow run status for the specified event type
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$WORKFLOWS_API_URL")

# Check if the API call was successful
if [ $? -ne 0 ]; then
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
echo "API call failed after $MAX_RETRIES attempts."
exit 1
else
echo "API call failed. Retrying ($RETRY_COUNT/$MAX_RETRIES)..."
sleep 5
continue
fi
fi

WORKFLOW_ID=$(echo "${RESPONSE}" | jq -r '.workflow_runs[0].id')
LATEST_WORKFLOW_ID=0

# Check if the workflow ID is different from the last detected workflow ID
if [ "$WORKFLOW_ID" != "$LATEST_WORKFLOW_ID" ]; then
LATEST_WORKFLOW_ID="$WORKFLOW_ID"
echo "fetching the recently submitted workflow..."
for ((i=1; i<=5; i++)); do
sleep "$POLL_INTERVAL"
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$WORKFLOWS_API_URL")
NEW_WORKFLOW_ID=$(echo "${RESPONSE}" | jq -r '.workflow_runs[0].id')
if [ "$NEW_WORKFLOW_ID" != "$LATEST_WORKFLOW_ID" ]; then
LATEST_WORKFLOW_ID="$NEW_WORKFLOW_ID"
WORKFLOW_ID=$LATEST_WORKFLOW_ID
break
fi
done
fi

WORKFLOW_API_URL="https://api.github.com/repos/${REPO}/actions/runs/${WORKFLOW_ID}"
WORKFLOW_URL="https://github.com/${REPO}/actions/runs/${WORKFLOW_ID}"
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$WORKFLOW_API_URL")
STATUS=$(echo "${RESPONSE}" | jq -r '.status')
CONCLUSION=$(echo "${RESPONSE}" | jq -r '.conclusion')

echo "WORKFLOW_ID: ${WORKFLOW_ID}"
echo "URL: ${WORKFLOW_URL}"

# Poll up to 5 times to check for an in_progress status of the most recently submitted.
# Once it finds an in_progress or queued workflow, it will keep polling until the workflow is completed successfully or failed.
if [ "${STATUS}" == "in_progress" ] || [ "${STATUS}" == "queued" ]; then
echo "Workflow in progress for ${REPO}."

while [ "${STATUS}" == "in_progress" ]; do
sleep "$POLL_INTERVAL"
RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$WORKFLOW_API_URL")
STATUS=$(echo "${RESPONSE}" | jq -r '.status')
CONCLUSION=$(echo "${RESPONSE}" | jq -r '.conclusion')
done

if [ "${STATUS}" == "completed" ]; then
if [ "${CONCLUSION}" == "success" ]; then
echo "Workflow completed successfully for ${REPO}."
exit 0
else
echo "Workflow failed for ${REPO}."
exit 1
fi
fi

elif [ "${STATUS}" == "completed" ]; then
if [ "${CONCLUSION}" == "success" ]; then
echo "Workflow completed successfully for ${REPO}."
exit 0
fi

else
echo "Either workflow ${WORKFLOW_ID} failed or is stuck for ${REPO}."
echo "Check at URL: ${WORKFLOW_API_URL}"
exit 1
fi
78 changes: 78 additions & 0 deletions .github/workflows/trigger-auto-csm-release-golibs-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0

# Trigger workflow for auto-release of CSM projects
name: Trigger Release of Dell Libraries

on:
workflow_dispatch:

jobs:
release_independent_repos:
name: Release Independent Go Libraries
runs-on: ubuntu-latest
strategy:
matrix:
repo:
[
"dell/goiscsi",
"dell/gonvme",
"dell/gocsi",
"dell/gofsutil",
"dell/gopowerstore",
"dell/gopowerscale",
"dell/gopowermax",
"dell/gounity",
"dell/goscaleio",
"dell/dell-csi-extensions",
]
steps:
- name: Trigger Release of ${{ matrix.repo }}
id: release
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: ${{ matrix.repo }}
event-type: release-go-libs
client-payload: |
{
"ref": "${{ github.ref }}",
"sha": "${{ github.sha }}"
}
- name: Check status of triggered workflows for release of ${{ matrix.repo }}
run: |
curl -sfL https://raw.githubusercontent.com/dell/common-github-actions/main/.github/scripts/check_workflow_status.sh -o check_workflow_status.sh
chmod +x check_workflow_status.sh
bash check_workflow_status.sh ${{ secrets.PERSONAL_ACCESS_TOKEN }} ${{ matrix.repo }} "repository_dispatch"
shell: bash

release_dependent_repo:
name: Release Dependent Go Libraries
runs-on: ubuntu-latest
needs: release_independent_repos
strategy:
matrix:
repo: ["dell/gobrick"]
steps:
- name: Trigger Release of ${{ matrix.repo }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: ${{ matrix.repo }}
event-type: release-go-libs
client-payload: |
{
"ref": "${{ github.ref }}",
"sha": "${{ github.sha }}"
}
- name: Check status of triggered workflows for release of ${{ matrix.repo }}
run: |
curl -sfL https://raw.githubusercontent.com/dell/common-github-actions/main/.github/scripts/check_workflow_status.sh -o check_workflow_status.sh
chmod +x check_workflow_status.sh
bash check_workflow_status.sh ${{ secrets.PERSONAL_ACCESS_TOKEN }} ${{ matrix.repo }} "repository_dispatch"
shell: bash
28 changes: 28 additions & 0 deletions .github/workflows/update-libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,31 @@ jobs:
Auto-generated by [common-github-actions](https://github.com/dell/common-github-actions)
sign-commits: true
delete-branch: true

- name: Wait for PR to be merged
Comment thread
shaynafinocchiaro marked this conversation as resolved.
run: |
branch="update-dependencies-to-latest-released"
echo "Checking if there is an open PR for the branch '$branch'..."
Comment thread
khareRajshree marked this conversation as resolved.

# Retrieve the list of open PRs for the specified branch.
pr_list=$(gh pr list --head "$branch" --json number)

# Count the number of open PRs using jq
pr_count=$(echo "$pr_list" | jq '. | length')

if [ "$pr_count" -eq 0 ]; then
echo "No open PR found for the branch '$branch'."
else
echo "Waiting for the PR to be merged. Please merge the PR manually."
while true; do
pr_status=$(gh pr view "$branch" --json state --jq '.state')
if [ "$pr_status" = "MERGED" ]; then
echo "PR has been merged."
break
fi
echo "PR not merged yet. Sleeping for 1 minute..."
sleep 60
done
fi
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}