添加 action.yaml

This commit is contained in:
hy 2024-04-26 17:55:11 +08:00
commit 7ab983ceb0
1 changed files with 36 additions and 0 deletions

36
action.yaml Normal file
View File

@ -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"