-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (82 loc) · 3.35 KB
/
packProcessor.yml
File metadata and controls
95 lines (82 loc) · 3.35 KB
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
90
91
92
93
94
name: Build and Deploy Packs
on:
push:
branches: [ main ]
paths:
- "packFolder/**"
env:
packsStoreFile: "cIPacksStore.json"
jobs:
build_pack:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14.x"
- name: Install Dependencies
run: |
cd packFolder
npm install
- name: Find pushed directory
id: find_dir
run: |
echo "::set-output name=dir::$(find packFolder -type d -name 'cI.*' -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2 | xargs basename)"
- name: Get pack data
id: pack_data
run: |
echo "::set-output name=packdata::$(jq -r ".[] | select(.name == \"${{ needs.build_pack.outputs.name }}\") | {name: .name, description: .description, author: .pack_maker, icon_author: .author, filename: \"${{ needs.build_pack.outputs.name }}.cIPack\"}" ${env.packsStoreFile})"
shell: bash
- name: Append pack data to packs store
id: append_data
run: |
packname=$(echo "${{ steps.find_dir.outputs.dir }}" | sed 's/cI\.//')
manifest_file="packFolder/${{ steps.find_dir.outputs.dir }}/cIManifest.json"
manifest_content=$(cat $GITHUB_WORKSPACE/cIPackStore.json|sed 's/.$//')
if echo "$packname" | grep -q "$manifest_content"
then
exit 0
fi
author=$(jq -r '.pack_maker' "$manifest_file")
icon_author=$(jq -r '.maker' "$manifest_file")
description=$(jq -r '.description' "$manifest_file")
pack_file="$packname.cIPack"
new_data="{\"name\":\"$packname\",\"description\":\"$description\",\"author\":\"$author\",\"icon_author\":\"$icon_author\",\"filename\":\"$pack_file\"}"
echo $manifest_content
echo "$manifest_content, $new_data]" > "$GITHUB_WORKSPACE/cIPackStore.json"
printf "\n* [$packname](/packs/$pack_file)" >> "$GITHUB_WORKSPACE/README.md"
echo "pauthor=$author" >> $GITHUB_ENV
echo "pname=$packname" >> $GITHUB_ENV
echo "pdesc=$description" >> $GITHUB_ENV
env:
packsStoreFile: ${{ env.packsStoreFile }}
pauthor: ${{ env.pauthor }}
pname: ${{ env.pname }}
pdesc: ${{ env.pdesc }}
- name: Set up packDir environment variable
run: echo "packDir=../packDir" >> $GITHUB_ENV
- name: Zip and move pack folder
working-directory: packFolder
run: |
name=$(echo "${{ steps.find_dir.outputs.dir }}" | sed 's/cI\.//')
zip -r "$name.cIPack" "cI.$name" -i "*"
mv "$name.cIPack" ../packs/
mv "cI.$name" "$packDir/$name"
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
token: ${{ secrets.PACKBUILDER }}
commit_message: ${{ github.event.head_commit.message }}
- name: Send Discord webhook with embed
uses: tsickert/discord-webhook@v5.3.0
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
content: <@&1086188262999216201>
embed-title: A new pack appeared!
embed-description: |
**${{ env.pname }}** by ${{ env.pauthor }}
${{ env.pdesc }}