-
Notifications
You must be signed in to change notification settings - Fork 4
41 lines (33 loc) · 1.27 KB
/
merge_greetings.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
name: Merge greeting
on:
pull_request:
types: [closed]
jobs:
greet:
runs-on: ubuntu-latest
steps:
- name: Fetch gifs
run: curl "https://api.giphy.com/v1/gifs/search?q=congratulation&api_key=YRosHbxsmDAZ6JI7xZ0M5J4EqpMb3xKj&limit=100" > .gifs
- name: Select random gif and comment issue
uses: actions/github-script@v5
with:
script: |
const fs = require('fs');
try {
const gifs = JSON.parse(fs.readFileSync('.gifs').toString());
core.info(`Fetched ${gifs.data.length} gifs`);
const randomIndex = Math.floor(Math.random() * (gifs.data.length - 1));
core.info(`Selected gif number ${randomIndex}`);
const gif = gifs.data[randomIndex];
const url = gif.images.original.url
core.info(`Url : ${url}`);
const { owner, repo } = context.repo;
const { data } = github.rest.issues.createComment({
owner,
repo,
issue_number: context.issue.number,
body: `![Congratulations](${url})`,
});
} catch (err) {
core.setFailed(err.message);
}