-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (85 loc) · 3.15 KB
/
like.yml
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
name: Add Like
on:
issues:
types:
- labeled
jobs:
add-like:
env:
author: ${{github.event.issue.user.login}}
if: github.event.label.name == 'like'
runs-on: ubuntu-latest
name: commit and push like
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Create local changes
run: |
#FIND=$(grep -Fx "$author" likers.txt)
if grep -Fxq "$author" likers.txt
#if [[! -z "$FIND"]]
then
echo "Try again!"
else
echo "$author" >> likers.txt
#and update counter
LIKES=$(wc -l < likers.txt);REPLACE=$(echo "<sub><b><i>Like counter: ${LIKES}</i></b></sub>");(head -9 README.md; echo "$REPLACE"; tail -n +11 README.md) > foobar && mv foobar README.md
fi
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
add-mutable-like:
env:
author: ${{github.event.issue.user.login}}
if: github.event.label.name == 'like-mutable'
runs-on: ubuntu-latest
name: commit and push mutable like
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Create local changes
run: |
if grep -Fxq "$author" likers-mutable.txt
then
echo "Try again!"
else
echo "$author" >> likers-mutable.txt
#and update counter
LIKES=$(wc -l < likers-mutable.txt);REPLACE=$(echo "<sub><b><i>Like counter: ${LIKES}</i></b></sub>");(head -18 README.md; echo "$REPLACE"; tail -n +20 README.md) > foobar && mv foobar README.md
fi
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
unlike:
env:
author: ${{github.event.issue.user.login}}
if: github.event.label.name == 'unlike-mutable'
runs-on: ubuntu-latest
name: commit and push mutable unlike
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Create local changes
run: |
LINE=$(grep -Fx "$author" likers-mutable.txt -n| cut -d ":" -f 1)
if [ -z "$LINE" ]
then
echo "Try again! You haven't already liked"
else
#withdraw like
sed -i "${LINE}d" likers-mutable.txt
#and update counter
LIKES=$(wc -l < likers-mutable.txt);REPLACE=$(echo "<sub><b><i>Like counter: ${LIKES}</i></b></sub>");(head -18 README.md; echo "$REPLACE"; tail -n +20 README.md) > foobar && mv foobar README.md
fi
- name: Commit & Push changes unlike
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}