Reputation: 2539
This is my action script:
name: Build
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: |
whoami
sudo mkdir /first_org
sudo chmod -R 777 /first_org
cd /first_org
git clone https://github.com/first_org/site
sudo rm -rf /first_org/site/.git
sudo mkdir /second_org
sudo chmod -R 777 /second_org
cd /second_org
git clone https://github.com/second_org/site
cp -a /first_org/site/. /second_org/site
cd /second_org/site
sudo apt-get update
sudo apt install nodejs
npm build
The /first_org/site
is a public repo, but the /second_org/site
is a private repo.
I don't use action/checkout@v2
because it doesn't let us specify an ABSOLUTE path to clone into. Thus I had to use pure shell commands.
This action belongs to /second_org/site
repo, thus based on docs, I can use GITHUB_TOKEN
to access it. But none of the examples show how can I use it in a simple git clone
command.
How can I use GITHUB_TOKEN
in my shell?
Upvotes: 2
Views: 6348
Reputation: 22890
You can clone using a token that way in shell (bash):
git clone https://<token>@github.com/<owner>/<repoName>.git
Note that the GITHUB_TOKEN
might not have enough scope permission to be used on private repo. In that case, you will need to use a PAT.
Here is an example of an action I created cloning a repo in bash (as reference): https://github.com/GuillaumeFalourd/create-other-repo-branch-action/blob/main/action.yml
Upvotes: 5