-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
147 lines (135 loc) · 5.41 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: "Get artifact from GCS"
description: "Uses main-quest/actions.gsutil"
inputs:
key:
description: "Service account json key, base64 encrypted or not"
required: true
bucket:
description: |
"Specify bucket name or leave empty to use the one generated by main-quest/actions.gsutil.artifact.bucketname"
required: false
run_id:
description: "Optionally specify another run to download the artifact from. Leave empty to download from the current run"
required: false
name:
description: "Artifact name. Artifacts are stored in folders under <bucket>/run-<run-id>/<artifact-name>/"
required: true
path:
description: "Destination. If it ends with a '/', a directory will be created if it doesn't already exist. If not specified, it'll download to the current directory"
required: false
default: "./"
unzip:
description: "Unzip all zip files found in the destination. Note that this is just a post-download step, and no files are removed (only replaced, in case archives contain multiple files with same relative paths)"
required: false
default: 'false'
runs:
using: "composite"
steps:
- name: Get bucket name
id: bucket_name_getter
uses: main-quest/actions.gsutil.artifact.bucketname@master
with:
bucket: ${{ inputs.bucket }}
#/OS
- name: "Make dirs if they don't exist [UNIX]"
if: runner.os != 'Windows'
shell: bash
run: |
s="${{ github.action_path }}/make_dirs.sh"
p="${{ inputs.path }}"
chmod +x "$s"
"$s" "$p"
- name: "Make dirs if they don't exist [WIN]"
if: runner.os == 'Windows'
# shell: wsl bash --noprofile --norc -euo pipefail "$(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
# run: |
# s=$(wslpath "${{ github.action_path }}/make_dirs.sh")
# p=$(wslpath "${{ inputs.path }}")
# chmod +x "$s"
# "$s" "$p"
shell: powershell
run: |
$s="$(wsl bash --noprofile --norc -euo pipefail -c 'wslpath ''${{ github.action_path }}/make_dirs.sh''')"
echo "Script debug: $s"
wsl bash --noprofile --norc -euo pipefail -c "chmod +x '$s'"
wsl bash --noprofile --norc -euo pipefail -c "sed -i 's/\r`$//' '$s'"
$p="$(wsl bash --noprofile --norc -euo pipefail -c 'wslpath ''${{ inputs.path }}''')"
$cmd = 'export GITHUB_OUTPUT="$(wslpath '''
$cmd += "$env:GITHUB_OUTPUT"
$cmd += ''')"'
$cmd += " && '$s'"
$cmd += ' '''
$cmd += "$p"
$cmd += ''''
wsl bash --noprofile --norc -euo pipefail -c "$cmd"
#OS/
#/OS
- name: "Convert path [UNIX]"
id: path_converter_unix
if: runner.os != 'Windows'
shell: bash
run: |
p="${{ inputs.path }}"
# echo "::set-output name=value::$p"
echo "value=$p" >> "$GITHUB_OUTPUT"
- name: "Convert path [WIN]"
id: path_converter_win
if: runner.os == 'Windows'
# shell: wsl bash --noprofile --norc -euo pipefail "$(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
# run: |
# p=$(wslpath "${{ inputs.path }}")
# # echo "::set-output name=value::$p"
# echo "value=$p" >> "$env:GITHUB_OUTPUT"
shell: powershell
run: |
$p="$(wsl bash --noprofile --norc -euo pipefail -c 'wslpath ''${{ inputs.path }}''')"
echo "value=$p" >> "$env:GITHUB_OUTPUT"
#OS/
#/OS
- name: "Get run id [UNIX]"
id: run_id_getter_unix
if: runner.os != 'Windows'
shell: bash
run: |
run_id="${{ inputs.run_id }}"
if [ -z "$run_id" ]; then
run_id="${{ github.run_id }}"
fi
# echo "::set-output name=value::$run_id"
echo "value=$run_id" >> "$GITHUB_OUTPUT"
- name: "Get run id [WIN]"
id: run_id_getter_win
if: runner.os == 'Windows'
# shell: wsl bash --noprofile --norc -euo pipefail "$(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
# run: |
# run_id="${{ inputs.run_id }}"
# if [ -z "$run_id" ]; then
# run_id="${{ github.run_id }}"
# fi
# # echo "::set-output name=value::$run_id"
# echo "value=$run_id" >> "$env:GITHUB_OUTPUT"
shell: powershell
run: |
$run_id="${{ inputs.run_id }}"
if (-not $run_id)
{
$run_id="${{ github.run_id }}"
}
echo "value=$run_id" >> "$env:GITHUB_OUTPUT"
#OS/
- uses: main-quest/actions.gsutil@master
with:
key: ${{ inputs.key }}
do: -m cp -r gs://${{ steps.bucket_name_getter.outputs.bucket_name }}/${{ steps.run_id_getter_unix.outputs.value }}${{ steps.run_id_getter_win.outputs.value }}/${{ inputs.name }}/* ${{ steps.path_converter_unix.outputs.value }}${{ steps.path_converter_win.outputs.value }}
#/OS
- name: "Unzip all .zip files if asked [UNIX]"
if: runner.os != 'Windows' && inputs.unzip == 'true'
shell: bash
working-directory: ${{ inputs.path }}
run: unzip *.zip
- name: "Unzip all .zip files if asked [WIN]"
if: runner.os == 'Windows' && inputs.unzip == 'true'
shell: powershell
working-directory: ${{ inputs.path }}
run: Expand-Archive *.zip
#OS/