diff --git a/.github/workflows/delete_workflow_runs.sh b/.github/workflows/delete_workflow_runs.sh new file mode 100755 index 00000000..422678a0 --- /dev/null +++ b/.github/workflows/delete_workflow_runs.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +set -e + +if [ $# -eq 0 ]; then + echo "Error: No workflow name provided." + echo "Usage: $0 " + exit 1 +fi + +WORKFLOW_NAME="$1" + +echo "Fetching repository information..." +REPO_INFO=$(gh repo view --json nameWithOwner) +REPO=$(echo $REPO_INFO | jq -r .nameWithOwner) +echo "Repository: $REPO" + +echo "Searching for workflows with name: '$WORKFLOW_NAME'" +WORKFLOW_IDS=$(gh api "/repos/$REPO/actions/workflows" | jq -r ".workflows[] | select(.name == \"$WORKFLOW_NAME\") | .id") + +if [ -z "$WORKFLOW_IDS" ]; then + echo "No workflows found with name '$WORKFLOW_NAME'" + exit 1 +fi + +echo "Found workflow(s) with ID(s): $WORKFLOW_IDS" + +delete_runs() { + local workflow_id=$1 + local page=$2 + echo "Fetching runs for workflow $workflow_id (page $page)..." + RUNS=$(gh api "/repos/$REPO/actions/workflows/$workflow_id/runs?per_page=100&page=$page") + RUN_COUNT=$(echo $RUNS | jq '.workflow_runs | length') + + if [ "$RUN_COUNT" -eq 0 ]; then + return 1 + fi + + echo "Deleting $RUN_COUNT runs..." + echo $RUNS | jq -r '.workflow_runs[].id' | while read -r run_id; do + echo "Deleting run $run_id" + gh api -X DELETE "/repos/$REPO/actions/runs/$run_id" + done + + return 0 +} + +for WORKFLOW_ID in $WORKFLOW_IDS; do + echo "Processing workflow ID: $WORKFLOW_ID" + page=1 + while delete_runs $WORKFLOW_ID $page; do + ((page++)) + done + + echo "All runs deleted for workflow ID $WORKFLOW_ID" + + echo "Deleting the workflow itself..." + gh api -X DELETE "/repos/$REPO/actions/workflows/$WORKFLOW_ID" + + echo "Workflow with ID $WORKFLOW_ID has been deleted." +done + +echo "All workflows named '$WORKFLOW_NAME' and their runs have been deleted." diff --git a/.github/workflows/deploy_gcp_bootnodes.yaml b/.github/workflows/deploy_gcp_bootnodes.yaml index fc61857c..a94eb7ec 100644 --- a/.github/workflows/deploy_gcp_bootnodes.yaml +++ b/.github/workflows/deploy_gcp_bootnodes.yaml @@ -33,7 +33,7 @@ jobs: uses: google-github-actions/auth@v2 with: workload_identity_provider: projects/784882329213/locations/global/workloadIdentityPools/github-oidc-pool/providers/github-oidc-provider - service_account: gh-masa-oracle-${{ github.ref_name }}@masa-chain.iam.gserviceaccount.com + service_account: gh-masa-oracle-test@masa-chain.iam.gserviceaccount.com - name: Install Google Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: diff --git a/.github/workflows/gh-release.yaml b/.github/workflows/gh-release.yaml deleted file mode 100644 index 6636054d..00000000 --- a/.github/workflows/gh-release.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: Create Github Release - -on: - push: - branches: - - main - - test - - dev - - paths-ignore: - - 'docs/**' - - '**.md' - - '.github/workflows/build.yaml' - - '.github/workflows/release.yaml' - - '.github/workflows/publish-to-docs.yaml' - - -permissions: - id-token: write - contents: write - -jobs: - prepare: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.extract_version.outputs.version }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Extract version from constants.go - id: extract_version - run: | - VERSION=$(grep 'Version = ' ./pkg/config/constants.go | awk '{print $NF}' | tr -d '"') - echo "Extracted version: $VERSION" - echo "::set-output name=version::$VERSION" - - release: - needs: prepare - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Create Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ needs.prepare.outputs.version }} - release_name: Release ${{ needs.prepare.outputs.version }} - body_path: ./RELEASE_NOTES.md - draft: false - prerelease: false - diff --git a/.github/workflows/publish-to-docs.yml b/.github/workflows/publish-to-docs.yml deleted file mode 100644 index a3b045dc..00000000 --- a/.github/workflows/publish-to-docs.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish to Docs - -on: - push: - branches: [ test ] # Change to main after mainnet is live and we publish masa-oracle to main (if desired) - paths: - - 'docs/**' - -jobs: - build: - runs-on: ubuntu-latest - container: pandoc/latex - steps: - - uses: actions/checkout@v4 - - name: Copy Readme - run: | - mkdir pub-docs - cp -r docs/welcome-to-masa pub-docs/ - cp -r docs/worker-node pub-docs/ - cp -r docs/oracle-node pub-docs/ - cp -r docs/validator-node pub-docs/ - cp -r docs/guides-and-tutorials pub-docs/ - cp RELEASE_NOTES.md pub-docs/ - - name: Pushes to another repository - uses: cpina/github-action-push-to-another-repository@main - env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} - with: - source-directory: 'pub-docs' - target-directory: 'docs/masa-oracle' - destination-github-username: 'masa-finance' - destination-repository-name: 'docs' - user-email: 13647606+H34D@users.noreply.github.com - target-branch: main \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 674922be..5d9ea5ca 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,4 +1,4 @@ -name: Go +name: Run Go Tests on: push: @@ -24,4 +24,4 @@ jobs: run: go mod tidy - name: Run tests - run: go test ./... \ No newline at end of file + run: go test ./...