Edits history of script submission #1635 for ' Create a registration token for a repository (github)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Github = {
      token: string;
    };
    /**
     * Create a registration token for a repository
     * Returns a token that you can pass to the `config` script. The token expires after one hour. You must authenticate
    using an access token with the `repo` scope to use this endpoint.
    
    #### Example using registration token
     
    Configure your self-hosted runner, replacing `TOKEN` with the registration token provided by this endpoint.
    
    ```
    ./config.sh --url https://github.com/octo-org/octo-repo-artifacts --token TOKEN
    ```
     */
    export async function main(auth: Github, owner: string, repo: string) {
      const url = new URL(
        `https://api.github.com/repos/${owner}/${repo}/actions/runners/registration-token`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 367 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Create a registration token for a repository
     * Returns a token that you can pass to the `config` script. The token expires after one hour. You must authenticate
    using an access token with the `repo` scope to use this endpoint.
    
    #### Example using registration token
     
    Configure your self-hosted runner, replacing `TOKEN` with the registration token provided by this endpoint.
    
    ```
    ./config.sh --url https://github.com/octo-org/octo-repo-artifacts --token TOKEN
    ```
     */
    export async function main(auth: Github, owner: string, repo: string) {
      const url = new URL(
        `https://api.github.com/repos/${owner}/${repo}/actions/runners/registration-token`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 921 days ago

  • nativets
    type Github = {
      token: string;
    };
    /**
     * Create a registration token for a repository
     * Returns a token that you can pass to the `config` script. The token expires after one hour. You must authenticate
    using an access token with the `repo` scope to use this endpoint.
    
    #### Example using registration token
     
    Configure your self-hosted runner, replacing `TOKEN` with the registration token provided by this endpoint.
    
    ```
    ./config.sh --url https://github.com/octo-org/octo-repo-artifacts --token TOKEN
    ```
     */
    export async function main(auth: Github, owner: string, repo: string) {
      const url = new URL(
        `https://api.github.com/repos/${owner}/${repo}/actions/runners/registration-auth.token`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 927 days ago