-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
50 lines (43 loc) · 1.43 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
name: 'Repos Dependency Update Action'
description: 'Update .repos file to match base or head branch'
author: 'Luis Camero'
inputs:
branch:
description: 'Branch to update .repos with.'
required: true
input:
description: 'Input .repos file.'
required: true
output:
description: 'Output .repos file.'
required: true
runs:
using: 'composite'
steps:
- name: Update .repos
id: repos-dep-update
shell: bash
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
pip install yq
sudo apt-get install jq
branch=${{ inputs.branch }}
rm -f ${{ inputs.output }}
echo -e "repositories:" >> ${{ inputs.output }}
for repo in $(yq -r '.repositories | to_entries[] | .key' ${{ inputs.input }}); do
type=$(yq -r .repositories.$repo.type ${{ inputs.input }})
url=$(yq -r .repositories.$repo.url ${{ inputs.input }})
version=$(yq -r .repositories.$repo.version ${{ inputs.input }})
info=$(git ls-remote $url)
if [[ $info == *"$branch"* ]]; then
version=$branch
else
version=$version
fi
echo -e " $repo:" >> ${{ inputs.output }}
echo -e " type: $type" >> ${{ inputs.output }}
echo -e " url: $url" >> ${{ inputs.output }}
echo -e " version: $version" >> ${{ inputs.output }}
done