-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
35 lines (33 loc) · 1.18 KB
/
action.yml
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
name: Get file from repository
description: Downloads a file from the repository using the github api.
inputs:
path:
description: What file to get.
required: true
name:
description: Name of file after downloading to temp directory.
required: true
token:
description: The token to use to query the Github API. Provided by the Actions context usually.
required: true
outputs:
path:
description: The file locally after downloading.
value: ${{ steps.get_file.outputs.path }}
runs:
using: composite
steps:
- name: Get File
shell: powershell
id: get_file
run: |
$Url = "${{ github.api_url }}/repos/${{ github.repository }}/contents/${{ inputs.path }}?ref=${{ github.ref_name }}"
$Headers = @{
'authorization' = 'Bearer ${{ inputs.token }}'
}
$Response = Invoke-RestMethod $Url -Headers $Headers
# Decode from Base64, Parse Yaml
$Text = $Response.content | %{ [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($_)) }
$Path = "${{ runner.temp }}/${{ inputs.name }}"
$Text | Out-File -FilePath $Path -Encoding UTF8
echo "::set-output name=path::$Path"