Code Monkey home page Code Monkey logo

clone-github-repo-action's Introduction

Clone Github Repository Action

Public workflows that use this action. Clone Public Repository Workflow Clone Private Repository Workflow

Title

Github Action to clone a public or private Github repository and access its content on others repositories' workflows.

What changed with the action v2 ?

This action v2 is using a composite action to be compatible with all operating systems (the v1 was using a Dockerfile that was only compatible with ubuntu-* runners).

What changed with the action v2.1 ?

You now have a new input parameter called depth, which is optional and has an empty default value. If you specify a depth value when using the action, it will be passed as the value for the --depth parameter of the git clone command. Otherwise, the clone will be done with the default depth, which is the full history.

What changed with the action v2.2 ?

You now have a new input parameter called branch, which is optional and uses main as default value. If you specify a branch value when using the action, it will be passed as the value for the --branch parameter of the git clone command.

What changed with the action v2.3 ?

You now have a new input parameter called submodule, which is optional and uses false as default value. If you specify the submodule value when using the action as true, it will clone the submodule along with the repository.

How to use this action?

Create a new .yml file on your .github/workflows directory.

Field Mandatory Observation
owner YES Ex: octocat
repository YES Ex: clone-github-repo-action
branch NO Ex: main (default)
depth NO 1 Ex: most recent commit
submodule NO false or true
access-token NO How to create a PAT

You can use one of those as reference:

For a public repository (with depth)

- name: Clone GuillaumeFalourd/poc-github-actions PUBLIC repository
  uses: GuillaumeFalourd/[email protected]
  with:
    depth: 1
    branch: 'main'
    owner: 'GuillaumeFalourd'
    repository: 'poc-github-actions'

For a private repository

To use this action to clone a PRIVATE repository the Github User/Admin has access to, it's necessary to create a PERSONAL ACCESS TOKEN with REPOSITORY scopes.

- name: Clone GuillaumeFalourd/formulas-training PRIVATE repository
  uses: GuillaumeFalourd/[email protected]
  with:
    owner: 'GuillaumeFalourd'
    repository: 'formulas-training'
    access-token: ${{ secrets.ACCESS_TOKEN }}

Access repository content

After using this action in your workflow, you can use the following command to access the cloned repository content:

cd <repository-name>

Step Example

- name: Access cloned repository content
  run: |
    cd <repository-name>
    ls -la

Licensed

☞ This repository uses the Apache License 2.0

Contributing

Guidelines

(Made with contributors-img)

clone-github-repo-action's People

Contributors

dabao1955 avatar guillaumefalourd avatar whyakari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

clone-github-repo-action's Issues

How to clone private repo into docker buildx action?

Hi,

Forgive me for my ignorance if this is a weird way to go about it (I am just recently getting familiar with both Docker and Github workflows), but I am interested in using this GitHub action inside a workflow that builds and pushes a Docker image, to clone a private repository.

The way I hope it would work is something like:

  1. Run the GuillaumeFalourd/[email protected] action to git clone the private repository
  2. Somehow access that private repository within the docker/setup-buildx-action@v1 action and simply copy it over to the docker image like ADD ./PrivateRepo ./

Would something like this be possible using this action?

Thanks in advance,
Erik

Repo cloned as root

The repo appears to be cloned as root instead of the runner user. For example a repo cloned and ls -la run within returns:

drwxr-xr-x  3 root   root   4096 Mar  3 12:17 .
drwxr-xr-x 11 runner docker 4096 Mar  3 12:17 ..
drwxr-xr-x  8 root   root   4096 Mar  3 12:17 .git
-rw-r--r--  1 root   root     76 Mar  3 12:17 index.yaml

README.md: wrong version tag & actions.yml: contributions not sync?

https://github.com/CEllenvia/studious-octo-machine/actions/runs/5880372585/job/15946516043
As this action shows, the v2.1 actually need to be used with something other.
https://github.com/CEllenvia/studious-octo-machine/actions/runs/5880398248/job/15946604331
https://github.com/CEllenvia/studious-octo-machine/actions/runs/5880583251/job/15947194567
In these, Actions complained about the "Unexpected input(s) 'depth'" , which is unexpected to me.
The allowed input including: 'path-to-clone' or just nothing. Isn't it a under develop feature?
I also checked the commit history.
v3...main#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6
That's means that no tags now on market can correctly handle "depth" inputs.

Clone with member of the repo[not owner]

Hello
Recently I wanted to clone a repo that Im not owned that, but the owner gave me the access to do anything there.(so I can create my PAT too)
the flow code:

    - name: cloning deps
      uses: GuillaumeFalourd/[email protected]
      with:
        owner: 'RealOwner'
        branch: master
        repository: 'RepoName'
        access-token: ${{ secrets.PAT}}  ##  but this is my PAT, not the owner. how resolve this without requesting PAT from the owner?

Edit: why I asked this question?

because when I insert my PAT , it giving some errors:
fatal: could not read Username for 'https://github.com/': Device not configured

Solution

Im not sure but I think it can solve this problem.
the pattern that we should do: git clone https://username:[email protected]/username/repository.git

so we should add another input like username, and add something (in link and other lines)like this:

git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.thirduser }}:${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git

pull requested, please check and confirm that if it's ok.(Im not sure)
#13

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.