-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
150 lines (135 loc) · 7.31 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
148
149
150
name: "gsutil shortcut"
description: "Issues gsutil commands while also detecting the project id from the provided service account key"
inputs:
key:
description: Service account json key, base64 encrypted or not
required: true
do:
description: Command to exec
required: true
outputs:
project:
description: "The project id parsed from the key file. Might be removed as it's not needed anymore in the internal implementation"
value: ${{ steps.parser_unix.outputs.project_id }}${{ steps.parser_win.outputs.project_id }}
# email:
# description: "The email of the service account parsed from the key file"
# value: ${{ steps.parser.outputs.project_id }}
runs:
using: "composite"
steps:
#OS/
- name: Parse key [UNIX]
id: parser_unix
if: runner.os != 'Windows'
shell: bash
run: |
s='${{ github.action_path }}/parser.sh'
chmod +x "$s"
"$s" '${{ inputs.key }}'
# - name: Parse key [WIN]
# id: parser_win
# if: runner.os == 'Windows'
# # shell: wsl bash --noprofile --norc -euo pipefail -c "$(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
# # shell: wsl bash --noprofile --norc -euo pipefail -c "GITHUB_OUTPUT="$(wslpath '${{ env.GITHUB_OUTPUT }}')" $(s="$(wslpath '{0}')" && sed -i 's/\r$//' "$s" && echo "$s")"
# shell: powershell
# run: |
# wsl bash --noprofile --norc -euo pipefail -c "GITHUB_OUTPUT="$(wslpath '${{ env.GITHUB_OUTPUT }}')" $(s="$(wslpath '${{ github.action_path }}/parser.sh')" && sed -i 's/\r$//' "$s" && chmod +x "$s" && "$s" "${{ inputs.key }}")"
# wsl bash --noprofile --norc -euo pipefail -c "GITHUB_OUTPUT="$(wslpath '${{ env.GITHUB_OUTPUT }}')" $(s="$(wslpath '${{ github.action_path }}/parser.sh')" && sed -i 's/\r$//' "$s" && chmod +x "$s" && "$s" "${{ inputs.key }}")"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
# TODO actually try again the long form but using "$env:GITHUB_OUTPUT"
- name: Parse key [WIN]
id: parser_win
if: runner.os == 'Windows'
shell: powershell
run: |
$s="$(wsl bash --noprofile --norc -euo pipefail -c 'wslpath ''${{ github.action_path }}/parser.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'"
$cmd = 'export GITHUB_OUTPUT="$(wslpath '''
$cmd += "$env:GITHUB_OUTPUT"
$cmd += ''')"'
$cmd += " && '$s'"
$cmd += ' ''${{ inputs.key }}'''
wsl bash --noprofile --norc -euo pipefail -c "$cmd"
#/OS
#OS/
# - name: Running gsutil command [OSX]
- name: Running gsutil command [UNIX]
# if: runner.os == 'macOS'
if: runner.os != 'Windows'
shell: bash
run: |
key_is_encrypted='${{ steps.parser_unix.outputs.key_is_encrypted }}${{ steps.parser_win.outputs.key_is_encrypted }}'
project_id='${{ steps.parser_unix.outputs.project_id }}${{ steps.parser_win.outputs.project_id }}'
v_do='${{ inputs.do }}'
s='${{ github.action_path }}/gsutil_tool.sh'
chmod +x "$s"
"$s" '${{ inputs.key }}' "$key_is_encrypted" "$project_id" "$v_do"
- name: Running gsutil command [WIN]
if: runner.os == 'Windows'
shell: powershell
run: |
$s="$(wsl bash --noprofile --norc -euo pipefail -c 'wslpath ''${{ github.action_path }}/gsutil_tool.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'"
$key_is_encrypted='${{ steps.parser_unix.outputs.key_is_encrypted }}${{ steps.parser_win.outputs.key_is_encrypted }}'
$project_id='${{ steps.parser_unix.outputs.project_id }}${{ steps.parser_win.outputs.project_id }}'
$v_do='${{ inputs.do }}'
$cmd = 'export GITHUB_OUTPUT="$(wslpath '''
$cmd += "$env:GITHUB_OUTPUT"
$cmd += ''')"'
$cmd += " && '$s'"
$cmd += ' ''${{ inputs.key }}'''
$cmd += " '$key_is_encrypted'"
$cmd += " '$project_id'"
$cmd += " '$v_do'"
wsl bash --noprofile --norc -euo pipefail -c "$cmd"
#/OS
# Dropping usage of this dockerized action (can only be used on linux atm 17 Nov 2021), since we can just reuse the one for macOS
# - name: Running gsutil command [UNIX]
# if: runner.os != 'Windows' && runner.os != 'macOS'
# uses: actions-hub/gcloud@master
# env:
# PROJECT_ID: ${{ steps.parser_unix.outputs.project_id }}${{ steps.parser_win.outputs.project_id }}
# APPLICATION_CREDENTIALS: ${{ inputs.key }}
# with:
# args: ${{ inputs.do }}
# cli: gsutil
#/OS