git add metadata ; git commit -m"New image available" ; git push
Két probléma is adódott:
- Egyfelől nagyon ronda, persze működik, és a Jenkins-nek is megvan a joga írni a tárolót, de én valami kifinomultabb megoldásra vágytam.
- Másfelől pedig maga a sütés egy másik git tárolóból indul ki, szóval vagy valami ideiglenes könyvtárba dolgozok (/tmp, ram disk), aminek az életciklusát kezelni kell, vagy a git tárolóban a git tároló problémájával küzdök, és kényesen ügyelek rá, hogy mindkét tárolóba csak az oda illő dolgok kerüljenek be.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
: ${1?=File name is required} | |
file_name=$1 | |
GITHUB_ORG=mhmxs | |
GITHUB_REPO=test-metadata | |
GITHUB_USER=mhmxs | |
GITHUB_API_KEY=0ea72b***************** | |
GITHUB_REPO_URL=https://github.com/$GITHUB_ORG/$GITHUB_REPO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
head=$(curl -sf -u $GITHUB_USER:$GITHUB_API_KEY https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/git/refs/heads/master) | |
commitSha=$(echo $head | jq -r .object.sha) | |
commitUrl=$(echo $head | jq -r .object.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
treeSha=$(echo $commit | jq -r .tree.sha) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blob=$(curl -sf -u $GITHUB_USER:$GITHUB_API_KEY -X POST https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/git/blobs -d "{\"content\":\"$(base64 $file_name)\",\"encoding\":\"base64\"}") | |
blobSha=$(echo $blob | jq -r .sha) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newTree=$(curl -sf -u $GITHUB_USER:$GITHUB_API_KEY -X POST https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/git/trees -d \ | |
"{\"base_tree\":\"$treeSha\",\"tree\":[{\"path\":\"$file_name\",\"mode\":\"100644\",\"type\":\"blob\",\"sha\":\"$blobSha\"}]}") | |
newTreeSha=$(echo $newTree | jq -r .sha) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newCommit=$(curl -sf -u $GITHUB_USER:$GITHUB_API_KEY -X POST https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/git/commits -d \ | |
"{\"message\":\"Upload $file_name\",\"parents\":[\"$commitSha\"],\"tree\":\"$newTreeSha\"}") | |
newCommitSha=$(echo $newCommit | jq -r .sha) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s -u $GITHUB_USER:$GITHUB_API_KEY -X PATCH https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/git/refs/heads/master -d "{\"sha\":\"$newCommitSha\",\"force\":true}" | |
exit 0 |
very informative Post
VálaszTörlésExcellent and nice post. This is such a great resource that you are providing and you give it away for free. I love seeing that understands the value. I'm glad to have found this post as its such an interesting one! I have also something very interesting for you. Visit our blog post-
VálaszTörléshp envy 4520 not printing
Learn the simple way to connect Roku account.We have experienced experts to help you with Roku HDCP Error issue .If in any case you still have issues with Roku connected but not working, you can call Roku technical support team by 1 888-309-0939 at any time.Roku HDCP errorFix Roku Purple Screen
VálaszTörlés