Update offersku.json #136
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- 'offersku.json' | |
jobs: | |
createIssue: | |
env: | |
GH_TOKEN: ${{secrets.ISSUE_TOKEN}} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
name: Check out code | |
- name: handle-list | |
run: | | |
# 删除issue模板文件前的元信息 | |
cat .github/ISSUE_TEMPLATE/create_offersku.md > template.md | |
deleteRow=$(grep -n "\-\-\-" template.md | cut -d ":" -f 1 | sed -n '2p') | |
for ((index=0;index<$deleteRow;index++));do | |
sed -i '1d' template.md | |
done | |
# 创建milestone | |
milestone=$(cat offersku.json | jq '.milestone') | |
allMilestones=$(curl \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{github.token}}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{github.repository_owner}}/manufacture/milestones | jq '.[] | .title') | |
createFlag="true" | |
for item in $allMilestones;do | |
if [[ $item == $milestone ]];then | |
createFlag="false" | |
break | |
fi | |
done | |
if [[ $createFlag == "true" ]];then | |
curl \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{github.token}}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{github.repository_owner}}/manufacture/milestones \ | |
-d '{"title":'$milestone',"state":"open"}' | |
fi | |
list=$(jq "[.task[] | {appname:.appname,distribution:.distribution[],platform:.platform[],os:.os[],assignees:.assignees,updateornew:.updateornew}]" offersku.json) | |
length=$(echo $list | jq '.|length') | |
declare -A map | |
map=(["金晟"]="jinsheng200303" ["崔志坚"]="czj69233" ["欧玉成"]="cbnb233") | |
# 创建issue | |
for ((index=0;index<$length;index++));do | |
sleep 3 | |
appname=$(echo $list | jq -r ".[$index].appname") | |
distribution=$(echo $list | jq -r ".[$index].distribution") | |
platform=$(echo $list | jq -r ".[$index].platform") | |
os=$(echo $list | jq -r ".[$index].os") | |
assignee=${map[$(echo $list | jq -r ".[$index].assignees")]} | |
updateornew=$(echo $list | jq -r ".[$index].updateornew") | |
stone=$(echo $milestone | sed 's/\"//g') | |
applabel="App" | |
# 根据appname的值来决定applabel的值 | |
if [[ $appname == "websoft9" ]]; then | |
issue_number=$(gh issue create --assignee $assignee --title "$updateornew SKU $appname on $platform on $os" --body-file template.md --label "$distribution" --milestone "$stone" --project "商品生产发布" | awk -F "/" '{print $NF}') | |
else | |
issue_number=$(gh issue create --assignee $assignee --title "$updateornew SKU $appname on $platform on $os" --body-file template.md --label "$distribution,$applabel" --milestone "$stone" --project "商品生产发布" | awk -F "/" '{print $NF}') | |
fi | |
echo $issue_number | |
done |