Skip to content

joostvdg/github-cli-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub CLI Test

Links

To Build

make build

To Run

./ghcs

To Test

Create an API token, and this to the file apitoken, without extension. This is in the .gitignore file, so should not be commited ever, but double check to be sure.

Update the contents of config.toml to your repository info.

CONFIG_LOCATION=$(pwd)/config.toml
TOKEN_LOCATION=$(pwd)/apitoken
http :1323/ser number:=2 email=joostvdg@gmail.com course=mine 

Create A File In An Existing Repo Without Cloning

curl -X PUT -H 'Authorization: token yadayada' \
    -d '{"message": "Initial Commit","content": "bXkgbmV3IGZpbGUgY29udGVudHM="}' \
    https://api.github.com/repos/user/test/contents/so-test.txt

Manual Process

FILE_NAME=request.json
USER=joostvdg
REPO=github-cli-test-env
CONTENT=$(base64 --input request.json)
echo ${CONTENT}

Create New File

{
    "message": "my commit message",
    "committer": {
        "name": "Joost van der Griendt",
        "email": "joostvdg@gmail.com"
    },
    "content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
curl -X PUT -H 'Authorization: token ${TOKEN}' \
    -d '{"message": "Initial Commit","content": \"${CONTENT}"}' \
    https://api.github.com/repos/${USER}/${REPO}/contents/${FILE_NAME}

Update File

{
    "message": "my commit message",
    "committer": {
        "name": "Joost van der Griendt",
        "email": "joostvdg@gmail.com"
    },
    "content": "bXkgbmV3IGZpbGUgY29udGVudHM=",
    "sha": "95b966ae1c166bd92f8ae7d1c313e738c731dfc3"
}

First retrieve current sha.

SHA=$(curl -H 'Authorization: token ${TOKEN}' \
    https://api.github.com/repos/joostvdg/github-cli-test-env/contents/test.json \
    | jq .sha)
curl -X PUT -H 'Authorization: token ${TOKEN}' \
    -d '{"message": "Seconf","content": "ewogICAgImZvbyI6ICJiYXIyIgp9", "committer": {"name": "Joost van der Griendt","email": "joostvdg@gmail.com"}, "sha": "8a79687628fe86b467ec0e87e7e155c4661caa4f"}' \
    https://api.github.com/repos/joostvdg/github-cli-test-env/contents/test.json

Kubernetes

Create Secret

kubectl create secret generic ghcs-api-token --from-literal=apitoken=mysecrettoken

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published