-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.95 KB
/
commiticons.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
name: Generate Commiticon
# Controls when the action will run. Triggers the workflow on push
# events but only for the main branch
on:
push:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checkout latest commit
- name: Checkout
uses: actions/checkout@v2
# Fetch a dad joke from icanhazdadjoke and replace newlines with <br> tag
- name: Get a dad-joke
run: |
echo "::set-env name=TEMP::$(curl -H "Accept: text/plain" https://icanhazdadjoke.com/ | sed -r ':a;N;$!ba;s/\n/<br>/g' | tr -d '\r')"
# Replace double quotes with single quotes to avoid clashes in further text
- name: Escape double-quotes
run: |
echo "::set-env name=DAD_JOKE::$(echo "$TEMP" | tr \" \')"
# Fetch Commiticon and add as Commit Comment
- name: Fetch Commiticon and add as Commit Comment
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments \
-d "{\"body\":\"| ![Commiticon](https://avatars.dicebear.com/api/human/$GITHUB_SHA.svg?h=250) | $DAD_JOKE |\n|:-:|:-:|\"}"
# Write file to .commiticons folder
- name: Write Commiticon
run: |
curl https://avatars.dicebear.com/api/human/$(echo $GITHUB_SHA).svg?h=250 --output .commiticons/$(echo $GITHUB_SHA).svg
# Push changes
- name: Push Changes
run: |
git config user.name Amorpheuz
git config user.email connect@amorpheuz.dev
git add .commiticons/
git commit -m "Generated Commiticon for: $GITHUB_SHA"
git push