-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetgithubAsset.ps1
More file actions
45 lines (32 loc) · 1.19 KB
/
getgithubAsset.ps1
File metadata and controls
45 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# SET $TOKEN for PAT in Powershell session BEFORE RUNNING
$OWNER="timstockford"
$REPO="github_actions_templates"
$ASSETID=""
$ASSETNAME=""
$RELEASEID="26338451"
$RELEASEURL="https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASEID"
$ASSETURL=""
#To query github, use header 'Accept: application/vnd.github.v3'
#Get Asset ID from Release
$CurlOutput = curl.exe --header "Authorization: token $TOKEN" `
--header 'Accept: application/vnd.github.v3' `
--location $RELEASEURL
$objReleases = $curloutput |ConvertFrom-Json
$CurlOutput |Out-File -FilePath .\releases.json -Force
$ASSETID = $objReleases.assets[0].id
$ASSETNAME = $objReleases.assets[0].name
$ASSETURL = $objReleases.assets[0].url
echo "$ASSETID : $ASSETNAME"
echo "$ASSETURL"
#Download Asset from Release
curl.exe --header "Authorization: token $TOKEN" `
--header 'Accept: application/octet-stream' `
--output $ASSETNAME `
--location $ASSETURL
Get-ChildItem $ASSETNAME
# Test zip file extraction
$guid = New-Guid
$tmpfolder = "getgithubfile_$guid"
Expand-Archive -Path .\myFiles.zip -DestinationPath $tmpfolder
Get-ChildItem $tmpfolder -Recurse
Remove-Item $tmpfolder -Recurse -Force