diff --git a/.github/scripts/save-stats.sh b/.github/scripts/save-stats.sh index d9db444..f6b7497 100644 --- a/.github/scripts/save-stats.sh +++ b/.github/scripts/save-stats.sh @@ -9,7 +9,7 @@ mkdir $package_dir unzip -q $PROJECT_NAME-$PLATFORM-$VERSION.zip "$package_dir/pharo/bin/pharo" --headless $package_dir/image/$PROJECT_NAME.image eval " -| getResponse getContents downloads text timestamp filename putResponse | +| getResponse getContents downloads text timestamp filename body putResponse | Transcript show: 'Getting download stats... '. getResponse := ZnClient new url: @@ -55,33 +55,15 @@ timestamp := DateAndTime now asString. filename := ((timestamp first: 19) copyReplaceAll: ':' with: '') , '.csv'. -Transcript show: 'Uploading stats... '. -putResponse := ZnClient new - url: - 'https://api.github.com/repos/openponk/$REPOSITORY_NAME/contents/' - , filename; - accept: ZnMimeType applicationJson; - setBearerAuthentication: '$GITHUB_TOKEN'; - entity: (ZnEntity - with: '{ +Transcript show: 'Saving put request body... '. +body := '{ \"content\":\"' , text asByteArray base64Encoded , '\", \"message\":\"' , timestamp , '\", \"branch\":\"dls\" -}' - type: ZnMimeType applicationJson); - put\"; - response. +}'. -Transcript show: 'Checking upload went ok... '. -(putResponse status >= 300) ifTrue: [ - self error: (String streamContents: [ :s | - s << 'Put response status ' << putResponse status asString << '.'. - putResponse status == 404 ifTrue: [ - s - << - ' If this is the first build of this repository, manually create branch named dls (possibly with no files). This is whole body of response: ' - << putResponse entity contents ] ]) ]. -Transcript show: 'Finished... '. - -^ 'Uploaded ' , downloads asString , ' download count'\" +filename asFileReference writeStreamDo: [:s | s << body ]. +Transcript show: 'Saved put request body... '. " + +curl -X PUT 'https://api.github.com/repos/openponk/$REPOSITORY_NAME/contents/$CSVFILENAME' -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $GITHUB_TOKEN" -d `cat *.csv`