Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/gotd/td-0.1…
Browse files Browse the repository at this point in the history
…07.0
  • Loading branch information
jdutchak authored Aug 13, 2024
2 parents 776de56 + 8b417c6 commit 858166b
Show file tree
Hide file tree
Showing 19 changed files with 152 additions and 134 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/delete_workflow_runs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -e

if [ $# -eq 0 ]; then
echo "Error: No workflow name provided."
echo "Usage: $0 <workflow-name>"
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."
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
name: release

name: Deploy GCP Testnet Bootnodes
on:
push:
branches:
- main
- test
- dev

paths-ignore:
- 'docs/**'
- '**.md'
- '.github/workflows/build.yaml'
- '.github/workflows/gh-release.yaml'
- '.github/workflows/publish-to-docs.yaml'
tags:
- 'v*' # This will match any tag that starts with 'v'

permissions:
id-token: write
Expand All @@ -22,73 +12,60 @@ jobs:
build-and-release:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref == 'refs/heads/main' && 'main' || github.ref == 'refs/heads/test' && 'test' || 'dev' }}
name: "test" #will expand to other envs later, currently "test" deploys to the 5 GCP bootnodes
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Set Version
run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV

run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build Binary
run: |
make build
- id: auth
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: [email protected]
- name: Install Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
version: 'latest'
project_id: ${{ vars.GCP_PROJECT_ID }}

- name: Upload Binary and config for contracts npm modules to GCP
run: |
BINARY_NAME=$(git rev-parse --short HEAD)
gsutil cp ./masa-node gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/masa-node
gsutil cp ./masa-node gs://${{ vars.GCP_BUCKET_NAME }}/masa-node
BINARY_NAME=${GITHUB_REF#refs/tags/}
gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/masa-node
gsutil cp ./bin/masa-node gs://${{ vars.GCP_BUCKET_NAME }}/masa-node
gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/$BINARY_NAME/
gsutil cp ./contracts/* gs://${{ vars.GCP_BUCKET_NAME }}/
- name: Set environment output
id: set-env
run: echo "::set-output name=environment::${{ github.ref_name }}"

deploy:
needs: build-and-release
runs-on: ubuntu-latest
environment:
name: ${{ needs.build-and-release.outputs.environment }}
name: test
steps:
- id: auth
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: [email protected]
- name: Update Instance Metadata
run: |
ENVIRONMENT="${{ github.ref_name }}"
ENVIRONMENT="test"
echo "Looking for instances with env metadata: $ENVIRONMENT"
INSTANCES=$(gcloud compute instances list --filter="metadata.items.ENV=$ENVIRONMENT" --format="get(name)")
echo "Found instances: $INSTANCES"
for INSTANCE in $INSTANCES; do
ZONE=$(gcloud compute instances list --filter="name=($INSTANCE)" --format="get(zone)" --limit=1)
echo "Updating instance: $INSTANCE in zone: $ZONE"
gcloud compute instances add-metadata $INSTANCE --metadata masa-oracle-redeploy=latest --zone=$(echo $ZONE | tr -d '\n')
gcloud compute instances add-metadata $INSTANCE --metadata masa-oracle-redeploy=${GITHUB_REF#refs/tags/} --zone=$(echo $ZONE | tr -d '\n')
done
54 changes: 0 additions & 54 deletions .github/workflows/gh-release.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/publish-to-docs.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go
name: Run Go Tests

on:
push:
Expand All @@ -24,4 +24,4 @@ jobs:
run: go mod tidy

- name: Run tests
run: go test ./...
run: go test ./...
Binary file added docs/images/discord-add-bot-to-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-change-bot-permissions-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-change-bot-permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-copy-bot-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-create-a-new-application.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-get-all-guilds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-get-guild-channels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-install-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-message-content-intent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/discord-verify-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
24 changes: 20 additions & 4 deletions docs/oracle-node/discord-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ The Service Manager assesses the request and delegates the task to the appropria

## Discord Endpoints

The API provides one endpoint for interacting with Discord user data:
### Getting Guild and Channel IDs

To get all guilds (and their IDs) you can use the `/data/discord/guilds/all` endpoint.

> ![Get Guilds](/img/discord-get-all-guilds.png)
With the guild ID you can then use the `/data/discord/guilds/{guildID}/channels` endpoint to get all channels for that guild.

> ![Get Channels](/img/discord-get-guild-channels.png)
With the guild ID you can then use the `/data/discord/guilds/{guildID}/channels` endpoint to get all channels for that guild.

### Retrieve User Profile

The API provides one endpoint for interacting with Discord user data:

The `/data/discord/users/{userID}` endpoint retrieves a Discord user's profile. This can be particularly useful for understanding user demographics, personalizing interactions, or for further analysis in combination with other data points.

- **Endpoint:** `/data/discord/users/{userID}`
Expand Down Expand Up @@ -63,6 +75,10 @@ Example response:

### Retrieve Messages from a Discord Channel

> **Important**: To retrieve message content, you must toggle "Message Content Intent" in the Discord Developer Portal under the `Bot` section.
>
> ![Message Content Intent](/img/discord-message-content-intent.png)
The `/data/discord/channels/{channelID}/messages` endpoint retrieves messages from a specified Discord channel.

- **Endpoint:** `/data/discord/channels/{channelID}/messages`
Expand Down Expand Up @@ -162,11 +178,11 @@ Imagine a decentralized AI agent, "CommunityEngageAI," designed to analyze engag

### How CommunityEngageAI Leverages AI

1. **Data Collection:** CommunityEngageAI sends queries to the various endpoints to fetch profiles of active community members, messages from channels, and other relevant data.
1 . **Data Collection:** CommunityEngageAI sends queries to the various endpoints to fetch profiles of active community members, messages from channels, and other relevant data.

2. **Engagement Analysis:** Upon retrieving the data, CommunityEngageAI employs AI models to analyze engagement patterns, identify key influencers, and understand user demographics.
2 . **Engagement Analysis:** Upon retrieving the data, CommunityEngageAI employs AI models to analyze engagement patterns, identify key influencers, and understand user demographics.

3. **Personalized Interactions:** Leveraging the insights gained, CommunityEngageAI customizes interactions with community members, tailoring messages and content to enhance engagement and user satisfaction.
3 . **Personalized Interactions:** Leveraging the insights gained, CommunityEngageAI customizes interactions with community members, tailoring messages and content to enhance engagement and user satisfaction.

### Conclusion

Expand Down
5 changes: 5 additions & 0 deletions docs/oracle-node/discord-sentiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ The Discord sentiment analysis feature extends the Masa Node's capabilities to i

The sentiment analysis process begins by collecting Discord messages based on specific channel IDs, followed by sentiment evaluation using the chosen language models. The system is compatible with a variety of models, such as Claude and GPT variants, ensuring versatile and robust sentiment analysis.

> **Important**: To retrieve message content, you must toggle "Message Content Intent" in the Discord Developer Portal under the `Bot` section.
>
> ![Message Content Intent](/img/discord-message-content-intent.png)

### Models

```go
Expand Down
Loading

0 comments on commit 858166b

Please sign in to comment.