-
Notifications
You must be signed in to change notification settings - Fork 20
Add trigger to release Go client libraries #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
khareRajshree
merged 12 commits into
main
from
usr/khareRajshree/golibs-release-workflow
Mar 27, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
740a283
add trigger job for releasing golibs
khareRajshree a476501
Merge branch 'usr/khareRajshree/golibs-release-workflow' of https://g…
khareRajshree 3c5a82d
add trigger job for releasing golibs
khareRajshree a5c148b
review comments addressed
khareRajshree 322be26
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
khareRajshree 85165a2
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
shaynafinocchiaro 9a1a47b
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
shaynafinocchiaro 227f88a
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
khareRajshree 583cd8d
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
shaynafinocchiaro bf29fa4
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
harishp8889 1a7906a
Merge branch 'main' into usr/khareRajshree/golibs-release-workflow
khareRajshree da2ed98
formating reviewed
khareRajshree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| 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
78
.github/workflows/trigger-auto-csm-release-golibs-workflow.yaml
This file contains hidden or 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
| 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 |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.