forked from ipdxco/unified-github-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-github-actions.sh
executable file
·42 lines (37 loc) · 1.12 KB
/
update-github-actions.sh
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
#!/usr/bin/env bash
set -euo pipefail -o nounset
# If the script is run with RUNNER_DEBUG=1, print all statements executed
if [[ "${RUNNER_DEBUG:-}" == "1" ]]; then
set -x
fi
plan="$(mktemp)"
file1="$(mktemp)"
file2="$(mktemp)"
file3="$(mktemp)"
dependabot update github_actions org/repo --local . --output "$plan"
while read -r pr; do
if [[ -z "$pr" ]]; then
continue
fi
while read -r f; do
if [[ -z "$f" ]]; then
continue
fi
name="$(jq -r '.name' <<< "$f")"
cp -f "$name" "$file1"
jq -j '.content' <<< "$f" > "$file2"
git show HEAD:"$name" > "$file3"
for i in $(seq 1 "$(wc -l < "$file3")"); do
line1="$(sed -n "${i}p" "$file1")"
line2="$(sed -n "${i}p" "$file2")"
line3="$(sed -n "${i}p" "$file3")"
if [[ "$line1" == "$line3" ]]; then
echo "$line2"
elif [[ "$line2" == "$line3" ]]; then
echo "$line1"
else
echo "$line3"
fi
done > "$name"
done <<< "$(jq -c '.["updated-dependency-files"] | .[] // []' <<< "$pr")"
done <<< "$(yq -c '.output | map(select(.type == "create_pull_request")) | map(.expect.data) | .[]' "$plan")"