添加 action.yaml
This commit is contained in:
commit
7ab983ceb0
|
|
@ -0,0 +1,36 @@
|
|||
name: shell_hash
|
||||
description: 获取文件哈希
|
||||
|
||||
inputs:
|
||||
file_array:
|
||||
required: true
|
||||
description: 文件路径
|
||||
|
||||
outputs:
|
||||
hash:
|
||||
description: 文件哈希
|
||||
value: ${{ steps.get_hash.outputs.res }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: 获取最新发布版本号
|
||||
id: get_hash
|
||||
shell: bash
|
||||
run: |
|
||||
# 初始化 res 变量
|
||||
res=""
|
||||
fileStr =${{inputs.file_array}}
|
||||
# 读取 fileStr 变量中的每一行文件路径
|
||||
while IFS= read -r filepath; do
|
||||
# 获取文件的 MD5 哈希值
|
||||
file_hash=$(md5sum "$filepath" | awk '{print $1}')
|
||||
# 将哈希值追加到 res 变量中
|
||||
res+="$file_hash"
|
||||
done <<< "$fileStr"
|
||||
|
||||
# 计算 res 的哈希值
|
||||
final_hash=$(echo -n "$res" | md5sum | awk '{print $1}')
|
||||
|
||||
echo "res=$final_hash" >> "$GITHUB_OUTPUT"
|
||||
echo "final_hash=$final_hash"
|
||||
Loading…
Reference in New Issue