-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
245 lines (225 loc) · 8.59 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: "Checkout Repo"
description: "Action to checkout GIT Repository with special reference handling."
branding:
icon: "download"
color: "green"
inputs:
repository:
description: 'Repository name with owner. For example, actions/checkout'
default: ${{ github.repository }}
required: false
ref:
description: >
The branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that
event. Otherwise, uses the default branch.
required: false
default: ${{ github.ref }}
alt_ref:
description: >
The alternative branch, tag or SHA to checkout. When checking out the repository that
triggered a workflow, this defaults to the reference or SHA for that event. Otherwise, uses the default branch.
required: false
order:
description: >
Direction of sort in case of a regular expression for your reference. ('top' or 'down')
Example: In case if ref=v* with tags v1, v2, v3 you will get v3 as a valid reference
required: false
default: 'top'
token:
description: >
Personal access token (PAT) used to fetch the repository. The PAT is configured
with the local git config, which enables your scripts to run authenticated git
commands. The post-job step removes the PAT.
We recommend using a service account with the least permissions necessary.
Also when generating a new PAT, select the least scopes necessary.
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
required: false
default: ${{ github.token }}
path:
description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
required: false
default: ''
lfs:
description: 'Whether to download Git-LFS files'
required: false
default: 'false'
regex_next_to_last:
description: >
In case of a regular expression matches your selected sha with the head of your default branch: here you can select the behavior.
Is the value false (default) the found sha will be taken. Is the value true, the last matching regex before the matching sha will be taken.
Example: In case if ref=v* with tags v1, v2, v3 you will get v3 as a valid reference. Is the v3 on the same sha with your main (default branch) and this flag is true. We will switch to v2 (next to last).
required: false
default: 'false'
submodules:
description: >
Whether to checkout submodules: `true` to checkout submodules or `recursive` to
recursively checkout submodules.
required: false
default: 'false'
include:
description: >
Explicitly include files for LFS
required: false
default: '*'
exclude:
description: >
Explicitly exclude files for LFS
required: false
default: ''
runs:
using: "composite"
steps:
# Show debug information
- name: Show debug information
run: |
echo "github repo: ${{ github.repository }}"
echo "input repo: ${{ inputs.repository }}"
shell: bash
# Call normal checkout action: see https://github.com/actions/checkout
# use default branch (or the reference)
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
token: ${{ inputs.token }}
path: ${{ inputs.path }}
lfs: ${{ inputs.lfs }}
submodules: ${{ inputs.submodules }}
fetch-depth: 0
# Call normal checkout action: see https://github.com/actions/checkout
# this is neccessary for own ci test
- name: Checkout own action code
if: ${{ github.repository == 'rohmanngmbh/action-checkout-repo' }}
uses: actions/checkout@v4
with:
repository: rohmanngmbh/action-checkout-repo
ref: ${{ github.ref }}
path: .temp
# Call normal checkout action: see https://github.com/actions/checkout
- name: Checkout own action code
if: ${{ github.repository != 'rohmanngmbh/action-checkout-repo' }}
uses: actions/checkout@v4
with:
repository: rohmanngmbh/action-checkout-repo
ref: main # <<<<< release tag or main
path: .temp
# Run python (environment variables has to be set separately https://github.com/actions/runner/issues/665)
- name: Run handle reference on linux/mac
if: ${{ runner.os != 'Windows' }}
env:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_REPOSITORY: ${{ inputs.repository }}
INPUT_REF: ${{ inputs.ref }}
INPUT_ALT_REF: ${{ inputs.alt_ref }}
INPUT_ORDER: ${{ inputs.order }}
shell: bash
run: |
cd .temp
echo $RUSTUP_HOME
echo $PATH
export PATH="/home/rohbot/.cargo/bin:$PATH"
export PATH="/opt/rust/bin:$PATH"
export RUSTUP_HOME="/opt/rust"
python3 -m venv ~/venvs/venv3
source ~/venvs/venv3/bin/activate
echo "*************** Post-Run Checkout ***************"
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
python3 main.py
deactivate
python3 -m venv ~/venvs/venv3 --clear
rm -rf ~/venvs/venv3
cd ..
echo "*************** Start Checkout ***************"
# Run python (environment variables has to be set separately https://github.com/actions/runner/issues/665)
- name: Run handle reference on windows
if: ${{ runner.os == 'Windows' }}
env:
INPUT_TOKEN: ${{ inputs.token }}
INPUT_REPOSITORY: ${{ inputs.repository }}
INPUT_REF: ${{ inputs.ref }}
INPUT_ALT_REF: ${{ inputs.alt_ref }}
INPUT_ORDER: ${{ inputs.order }}
shell: cmd
run: |
echo "*************** Post-Run Checkout ***************"
cd .temp
pip install --upgrade pip
pip install -r requirements.txt
python main.py
cd ..
echo "*************** Start Checkout ***************"
# Show ref information
- name: Show ref information
run: |
echo "input_ref: ${{ inputs.ref }}"
echo "input_alt_ref: ${{ inputs.alt_ref }}"
echo "my_ref: ${{ env.my_ref }}"
echo "is_default_branch: ${{ env.is_default_branch }}"
echo "ref_type: ${{ env.ref_type }}"
shell: bash
# Switch reference of cloned repo
- name: Switch reference of cloned repo
if: ${{ inputs.path == '' }}
run: |
git checkout ${{env.my_ref}}
shell: bash
# Switch reference of cloned repo
- name: Switch reference of cloned repo
if: ${{ inputs.path != '' }}
run: |
cd ${{ inputs.path }}
git checkout ${{env.my_ref}}
shell: bash
# Get sha
- name: Get sha
if: ${{ inputs.path == '' }}
run: |
git rev-parse HEAD
shell: bash
# Get sha
- name: Get sha
if: ${{ inputs.path != '' }}
run: |
cd ${{ inputs.path }}
git rev-parse HEAD
shell: bash
# Handle git lfs stuff: see https://github.com/nschloe/action-cached-lfs-checkout
# in case of base path
- name: Create LFS file list
if: ${{ inputs.lfs == 'true' && inputs.path == '' }}
run: |
git lfs ls-files --long --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}" | cut -d ' ' -f1 | sort > .lfs-assets-id
shell: bash
- name: Restore LFS cache
if: ${{ inputs.lfs == 'true' && inputs.path == '' }}
uses: actions/cache@v4
id: lfs-cache-base
with:
path: .git/lfs
key: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
if: ${{ inputs.lfs == 'true' && inputs.path == '' }}
run: git lfs pull --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}"
shell: bash
# in case of special path
- name: Create LFS file list
if: ${{ inputs.lfs == 'true' && inputs.path != '' }}
run: |
cd ${{ inputs.path }}
git lfs ls-files --long --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}" | cut -d ' ' -f1 | sort > .lfs-assets-id
shell: bash
- name: Restore LFS cache
if: ${{ inputs.lfs == 'true' && inputs.path != '' }}
uses: actions/cache@v4
id: lfs-cache-special
with:
path: ${{ inputs.path }}/.git/lfs
key: lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
if: ${{ inputs.lfs == 'true' && inputs.path != ''}}
run: |
cd ${{ inputs.path }}
git lfs pull --include "${{ inputs.include }}" --exclude "${{ inputs.exclude }}"
shell: bash