1. Packages
  2. Github Provider
  3. API Docs
  4. getRepositoryFile
GitHub v6.3.2 published on Friday, Oct 11, 2024 by Pulumi

github.getRepositoryFile

Explore with Pulumi AI

github logo
GitHub v6.3.2 published on Friday, Oct 11, 2024 by Pulumi

    This data source allows you to read files within a GitHub repository.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const foo = github.getRepositoryFile({
        repository: fooGithubRepository.name,
        branch: "main",
        file: ".gitignore",
    });
    
    import pulumi
    import pulumi_github as github
    
    foo = github.get_repository_file(repository=foo_github_repository["name"],
        branch="main",
        file=".gitignore")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := github.LookupRepositoryFile(ctx, &github.LookupRepositoryFileArgs{
    			Repository: fooGithubRepository.Name,
    			Branch:     pulumi.StringRef("main"),
    			File:       ".gitignore",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = Github.GetRepositoryFile.Invoke(new()
        {
            Repository = fooGithubRepository.Name,
            Branch = "main",
            File = ".gitignore",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.GithubFunctions;
    import com.pulumi.github.inputs.GetRepositoryFileArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var foo = GithubFunctions.getRepositoryFile(GetRepositoryFileArgs.builder()
                .repository(fooGithubRepository.name())
                .branch("main")
                .file(".gitignore")
                .build());
    
        }
    }
    
    variables:
      foo:
        fn::invoke:
          Function: github:getRepositoryFile
          Arguments:
            repository: ${fooGithubRepository.name}
            branch: main
            file: .gitignore
    

    Using getRepositoryFile

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getRepositoryFile(args: GetRepositoryFileArgs, opts?: InvokeOptions): Promise<GetRepositoryFileResult>
    function getRepositoryFileOutput(args: GetRepositoryFileOutputArgs, opts?: InvokeOptions): Output<GetRepositoryFileResult>
    def get_repository_file(branch: Optional[str] = None,
                            file: Optional[str] = None,
                            repository: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetRepositoryFileResult
    def get_repository_file_output(branch: Optional[pulumi.Input[str]] = None,
                            file: Optional[pulumi.Input[str]] = None,
                            repository: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetRepositoryFileResult]
    func LookupRepositoryFile(ctx *Context, args *LookupRepositoryFileArgs, opts ...InvokeOption) (*LookupRepositoryFileResult, error)
    func LookupRepositoryFileOutput(ctx *Context, args *LookupRepositoryFileOutputArgs, opts ...InvokeOption) LookupRepositoryFileResultOutput

    > Note: This function is named LookupRepositoryFile in the Go SDK.

    public static class GetRepositoryFile 
    {
        public static Task<GetRepositoryFileResult> InvokeAsync(GetRepositoryFileArgs args, InvokeOptions? opts = null)
        public static Output<GetRepositoryFileResult> Invoke(GetRepositoryFileInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRepositoryFileResult> getRepositoryFile(GetRepositoryFileArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: github:index/getRepositoryFile:getRepositoryFile
      arguments:
        # arguments dictionary

    The following arguments are supported:

    File string
    The path of the file to read.
    Repository string
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    Branch string
    Git branch. Defaults to the repository's default branch.
    File string
    The path of the file to read.
    Repository string
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    Branch string
    Git branch. Defaults to the repository's default branch.
    file String
    The path of the file to read.
    repository String
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    branch String
    Git branch. Defaults to the repository's default branch.
    file string
    The path of the file to read.
    repository string
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    branch string
    Git branch. Defaults to the repository's default branch.
    file str
    The path of the file to read.
    repository str
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    branch str
    Git branch. Defaults to the repository's default branch.
    file String
    The path of the file to read.
    repository String
    The repository to read the file from. If an unqualified repo name (without an owner) is passed, the owner will be inferred from the owner of the token used to execute the plan. If a name of the type "owner/repo" (with a slash in the middle) is passed, the owner will be as specified and not the owner of the token.
    branch String
    Git branch. Defaults to the repository's default branch.

    getRepositoryFile Result

    The following output properties are available:

    CommitAuthor string
    Committer author name.
    CommitEmail string
    Committer email address.
    CommitMessage string
    Commit message when file was last updated.
    CommitSha string
    The SHA of the commit that modified the file.
    Content string
    The file content.
    File string
    Id string
    The provider-assigned unique ID for this managed resource.
    Ref string
    The name of the commit/branch/tag.
    Repository string
    Sha string
    The SHA blob of the file.
    Branch string
    CommitAuthor string
    Committer author name.
    CommitEmail string
    Committer email address.
    CommitMessage string
    Commit message when file was last updated.
    CommitSha string
    The SHA of the commit that modified the file.
    Content string
    The file content.
    File string
    Id string
    The provider-assigned unique ID for this managed resource.
    Ref string
    The name of the commit/branch/tag.
    Repository string
    Sha string
    The SHA blob of the file.
    Branch string
    commitAuthor String
    Committer author name.
    commitEmail String
    Committer email address.
    commitMessage String
    Commit message when file was last updated.
    commitSha String
    The SHA of the commit that modified the file.
    content String
    The file content.
    file String
    id String
    The provider-assigned unique ID for this managed resource.
    ref String
    The name of the commit/branch/tag.
    repository String
    sha String
    The SHA blob of the file.
    branch String
    commitAuthor string
    Committer author name.
    commitEmail string
    Committer email address.
    commitMessage string
    Commit message when file was last updated.
    commitSha string
    The SHA of the commit that modified the file.
    content string
    The file content.
    file string
    id string
    The provider-assigned unique ID for this managed resource.
    ref string
    The name of the commit/branch/tag.
    repository string
    sha string
    The SHA blob of the file.
    branch string
    commit_author str
    Committer author name.
    commit_email str
    Committer email address.
    commit_message str
    Commit message when file was last updated.
    commit_sha str
    The SHA of the commit that modified the file.
    content str
    The file content.
    file str
    id str
    The provider-assigned unique ID for this managed resource.
    ref str
    The name of the commit/branch/tag.
    repository str
    sha str
    The SHA blob of the file.
    branch str
    commitAuthor String
    Committer author name.
    commitEmail String
    Committer email address.
    commitMessage String
    Commit message when file was last updated.
    commitSha String
    The SHA of the commit that modified the file.
    content String
    The file content.
    file String
    id String
    The provider-assigned unique ID for this managed resource.
    ref String
    The name of the commit/branch/tag.
    repository String
    sha String
    The SHA blob of the file.
    branch String

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo
    GitHub v6.3.2 published on Friday, Oct 11, 2024 by Pulumi