-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2.57 KB
/
merge_pr.yml
File metadata and controls
69 lines (59 loc) · 2.57 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
name: Merge PR
on:
pull_request_target:
types: [closed]
jobs:
merge-submission:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'Revert') == false
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Read metadata.json
id: read_metadata
run: |
SLUG=$(jq -r '.slug' submission/metadata.json)
NAME=$(jq -r '.name' submission/metadata.json)
COVER=$(jq -r '.cover' submission/metadata.json)
TOTAL=$(jq -r '.total' submission/metadata.json)
echo "::set-output name=slug::$SLUG"
echo "::set-output name=name::$NAME"
echo "::set-output name=cover::$COVER"
echo "::set-output name=total::$TOTAL"
- name: Create package folder
run: |
SLUG=${{ steps.read_metadata.outputs.slug }}
mkdir -p package/${SLUG}
- name: Update list.json
run: |
SLUG=${{ steps.read_metadata.outputs.slug }}
COMMITTER=${GITHUB_ACTOR}
jq 'del(.stickers) | .submitter = env.COMMITTER' submission/metadata.json | jq --argjson newItem "$(cat -)" '. += [$newItem]' list.json > tmp.json && mv tmp.json list.json
- name: Update list.md
run: |
SLUG=${{ steps.read_metadata.outputs.slug }}
NAME=${{ steps.read_metadata.outputs.name }}
URL="https://github.com/StickerManager/StickerShare/blob/main/package/${SLUG}/"
PACKAGE="[${NAME}](${URL})"
TOTAL=${{ steps.read_metadata.outputs.total }}
AUTHOR_NAME=$(jq -r '.author.name' submission/metadata.json)
AUTHOR_EMAIL=$(jq -r '.author.email' submission/metadata.json)
AUTHOR="[${AUTHOR_NAME}](mailto:${AUTHOR_EMAIL})"
SUBMITTER="${GITHUB_ACTOR}"
echo -e "| ${PACKAGE} | ${TOTAL} | ${AUTHOR} | ${SUBMITTER} | $(date -u) |" >> list.md
- name: Move submission to package folder
run: |
SLUG=${{ steps.read_metadata.outputs.slug }}
COVER=${{ steps.read_metadata.outputs.cover }}
mv submission/metadata.json package/${SLUG}/metadata.json
mv submission/${SLUG}.zip package/${SLUG}/pack.zip
mv submission/${COVER} package/${SLUG}/${COVER}
- name: Commit changes
run: |
SLUG=${{ steps.read_metadata.outputs.slug }}
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add package/ list.json list.md
git add -u submission/
git commit -m "Merge submission for \`${SLUG}\` by \`$GITHUB_ACTOR\`"
git push