-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yaml
89 lines (84 loc) · 3.12 KB
/
action.yaml
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
name: Update aqua-checksums.json
description: Update aqua-checksums.json
inputs:
working_directory:
required: false
prune:
required: false
default: false
skip_push:
required: false
default: false
read_checksum_token:
required: false
default: '' # When this input is an empty string, it doesn't override `AQUA_GITHUB_TOKEN`.
description: |
This token overrides `AQUA_GITHUB_TOKEN` to executes `aqua update-checksum`. It must have `contents:read` permission about all repositories
in tools managed by `aqua`. This input is useful to fetch checksum from private repositories.
runs:
using: composite
steps:
- shell: bash
working-directory: ${{inputs.working_directory}}
run: aqua update-checksum -deep
if: inputs.prune != 'true'
env:
AQUA_GITHUB_TOKEN: ${{ (inputs.read_checksum_token != '') && inputs.read_checksum_token || env.AQUA_GITHUB_TOKEN }}
- shell: bash
working-directory: ${{inputs.working_directory}}
run: aqua update-checksum -deep -prune
if: inputs.prune == 'true'
env:
AQUA_GITHUB_TOKEN: ${{ (inputs.read_checksum_token != '') && inputs.read_checksum_token || env.AQUA_GITHUB_TOKEN }}
- shell: bash
id: find
working-directory: ${{inputs.working_directory}}
run: |
set -eu
for p in aqua-checksums.json .aqua-checksums.json aqua/aqua-checksums.json aqua/.aqua-checksums.json .aqua/aqua-checksums.json .aqua/.aqua-checksums.json; do
if [ -f "$p" ]; then
echo "checksum_file=$p" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "::error ::aqua checksum json file isn't found"
exit 1
- shell: bash
working-directory: ${{inputs.working_directory}}
run: git add ${{steps.find.outputs.checksum_file}}
- shell: bash
if: inputs.skip_push == 'true'
run: |
set -eu
if [ -n "$WORKING_DIR" ]; then
CHECKSUM_FILE="$WORKING_DIR/$CHECKSUM_FILE"
fi
if ! git diff --cached --exit-code "${CHECKSUM_FILE}"; then
echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest."
exit 1
fi
env:
CHECKSUM_FILE: ${{steps.find.outputs.checksum_file}}
WORKING_DIR: ${{inputs.working_directory}}
- shell: bash
if: inputs.skip_push != 'true'
run: |
set -eu
if [ -n "$WORKING_DIR" ]; then
CHECKSUM_FILE="$WORKING_DIR/$CHECKSUM_FILE"
fi
if git diff --cached --exit-code "${CHECKSUM_FILE}"; then
exit 0
fi
echo "::error file=${CHECKSUM_FILE}::${CHECKSUM_FILE} isn't latest. A commit is pushed automatically to update ${CHECKSUM_FILE}."
branch=${GITHUB_HEAD_REF:-}
if [ -z "$branch" ]; then
branch=$GITHUB_REF_NAME
fi
aqua -c "$GITHUB_ACTION_PATH/aqua.yaml" exec -- ghcp commit -r "$GITHUB_REPOSITORY" -b "$branch" \
-m "chore(aqua): update $CHECKSUM_FILE" \
"$CHECKSUM_FILE"
exit 1
env:
CHECKSUM_FILE: ${{steps.find.outputs.checksum_file}}
WORKING_DIR: ${{inputs.working_directory}}