-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
103 lines (92 loc) · 3.49 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
name: "Put artifact on 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
name:
description: "Artifact name. Artifacts are stored in folders under <bucket>/run-<run-id>/<artifact-name>/"
required: true
path:
description: "Source file/dir"
required: true
zip:
description: "Upload a single zip file with all the files at 'path'"
required: false
default: false
runs:
using: "composite"
steps:
- name: "Get bucket name"
id: namer
uses: main-quest/actions.gsutil.artifact.bucketname@master
with:
bucket: ${{ inputs.bucket }}
#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
- name: "Upload raw"
uses: main-quest/actions.gsutil@master
if: inputs.zip == 'false'
with:
key: ${{ inputs.key }}
do: -m cp -r ${{ steps.path_converter_unix.outputs.value }}${{ steps.path_converter_win.outputs.value }} gs://${{ steps.namer.outputs.bucket_name }}/${{ github.run_id }}/${{ inputs.name }}/
#OS/
- name: "Zip files if asked [UNIX]"
id: zip_preparer_unix
if: runner.os != 'Windows' && inputs.zip == 'true'
shell: bash
run: |
name="${{ inputs.name }}"
path="${{ inputs.path }}"
d="$name"__zipped
mkdir -p "$d"
f="$d/$name.zip"
zip -r "$f" "$path"
# echo "::set-output name=file_path::$f"
echo "file_path=$f" >> "$GITHUB_OUTPUT"
- name: "Zip files if asked [WIN]"
id: zip_preparer_win
if: runner.os == 'Windows' && inputs.zip == 'true'
shell: powershell
run: |
$name="${{ inputs.name }}"
$path="${{ inputs.path }}"
$d="$name"+"__zipped"
New-Item -Type Directory -Force "$d" > $NULL
$f="$d/$name.zip"
Compress-Archive -Path "$path" -DestinationPath "$f"
# Note! The Win path needs to be converted to unix path under WSL
$f=$(wsl wslpath "$f")
# echo "::set-output name=file_path::$f"
echo "file_path=$f" >> "$env:GITHUB_OUTPUT"
#/OS
- name: "Upload zipped if asked"
uses: main-quest/actions.gsutil@master
if: inputs.zip == 'true'
with:
key: ${{ inputs.key }}
do: -m cp -r ${{ steps.zip_preparer_unix.outputs.file_path }}${{ steps.zip_preparer_win.outputs.file_path }} gs://${{ steps.namer.outputs.bucket_name }}/${{ github.run_id }}/${{ inputs.name }}/