Swirls

SWIRLS_

  • How it works
  • Pricing

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6
← DevOpsScheduleView on GitHub

OAuth GitHub Integration

Demonstrates OAuth auth blocks with GitHub client credentials.

http

Source

/**
 * Demonstrates the shape of an oauth auth block with the
 * client_credentials grant. Note: GitHub's token endpoint does not
 * actually support client_credentials -- swap in your own provider's
 * token URL to run this, or use a bearer auth block with a GitHub PAT.
 */

secret github_creds {
  label: "GitHub OAuth"
  vars: [GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GITHUB_API_URL]
}

auth github_oauth {
  label: "GitHub API"
  type: oauth
  secrets: github_creds
  grant_type: "client_credentials"
  client_id: GITHUB_CLIENT_ID
  client_secret: GITHUB_CLIENT_SECRET
  token_url: "https://github.com/login/oauth/access_token"
}

schedule daily_stats {
  label: "Daily Repo Stats"
  cron: "0 9 * * *"
}

workflow fetch_repo_stats {
  label: "Fetch Repo Stats"

  root {
    type: code
    label: "Configure"
    code: @ts {
      return { repo: "owner/repo" }
    }
    outputSchema: @json {
      {
        "type": "object",
        "properties": {
          "repo": { "type": "string" }
        }
      }
    }
  }

  node fetch_repo {
    type: http
    label: "Fetch repo info"
    url: @ts {
      const base = context.secrets.github_creds.GITHUB_API_URL || "https://api.github.com"
      return base + "/repos/" + context.nodes.root.output.repo
    }
    auth: github_oauth
    secrets: {
      github_creds: [GITHUB_API_URL]
    }
  }

  node extract {
    type: code
    label: "Extract stats"
    code: @ts {
      const repo = context.nodes.fetch_repo.output
      return {
        name: repo.full_name || context.nodes.root.output.repo,
        stars: repo.stargazers_count || 0,
        forks: repo.forks_count || 0,
        open_issues: repo.open_issues_count || 0,
        watchers: repo.watchers_count || 0
      }
    }
  }

  flow {
    root -> fetch_repo
    fetch_repo -> extract
  }
}

trigger on_stats {
  schedule:daily_stats -> fetch_repo_stats
  enabled: true
}

Flow

Trigger to workflow

daily_statsschedule
fetch_repo_stats
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Workflow nodes

CODE
Code Node
Configure
HTTP
HTTP Node
Fetch repo info
CODE
Code Node
Extract stats
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.