GithubHelp home page GithubHelp logo

nicky7787 / github-graphql-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from helaili/github-graphql-action

1.0 1.0 0.0 70 KB

An action which executes graphql queries

Dockerfile 13.19% JavaScript 50.34% HCL 36.47%

github-graphql-action's Introduction

github-graphql-action

An action that acts a client for GitHub's GraphQL API and can be chained. It means you can use a first instance to execute a GraphQL query and use its output to execute a GraphQL mutation.

Check a sample workflow and sample GraphqQL queries

Parameters

Argument ย  Description
query Query file path within the repo. Required
output The name of the file, relative to GITHUB_WORKSPACE, where the output will be stored. Defaults to github-graphql-action.json
url GraphQL endpoint URL. Defaults to https://api.github.com/graphql
accept Accept header to set in the query. Optional
log Set this argument to any value to enable logging to the console. Optional

Query file

The query file contains the GraphQL query or mutation to execute. Format is YAML based.

Static parameters

query: '
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
  	 name
   }
  }'
variables:
  owner: helaili
  name: github-graphql-action
action "GraphQL query" {
  uses = "./"
  secrets = ["GITHUB_TOKEN"]
  args = "--query .github/graphql_action/repository-static.query.yaml"
}

Command line based parameters

Variables values can also come from a command line argument.

query: '
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
  	 name
   }
  }'
variables:
  owner:
    type: arg
    name: owner
  name:
    type: arg
    name: name
action "GraphQL query" {
  uses = "./"
  secrets = ["GITHUB_TOKEN"]
  args = "--query .github/graphql_action/repository-args.query.yaml --owner helaili --name hello-vue"
}

File based parameters

Variable values can also come from a file, typically event.json which contains the event which triggered the action workflow (in ../workflow) or an arbitrary file (relative to /github/workspace) containing the result from a previous action (declared using the output command line parameter). This file is then processed by a jq query in order to extract the scalar value needed for the GraphQL query.

You can optionally add a cast parameter in order to convert the jq output to an Int, Float or Boolean

query:'
  query($owner:String!, $name:String!) {
    repository(owner:$owner, name:$name) {
      name
    }
  }'
variables:
  owner:
    type: jq
    file: ../workflow/event.json
    query: '.repository.owner.login'
  name:
    type: jq
    file: ../workflow/event.json
    query: '.repository.name'
action "GraphQL query" {
  uses = "./"
  secrets = ["GITHUB_TOKEN"]
  needs = "Repo Query Args"
  args = "--query .github/graphql_action/repository-jq.query.yaml --log true"
}

Mutation

query: '
  mutation pinIssue($issueId: ID!){
    pinIssue(input: { issueId: $issueId }) {
      issue {
        repository {
          id
        }
      }
    }
  }'
variables:
  issueId:
    type: jq
    file: ../workflow/event.json
    query: '.issue.node_id'

github-graphql-action's People

Contributors

dependabot[bot] avatar helaili avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.