This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
70 lines (63 loc) · 2.29 KB
/
goals-caching.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
name: push issues data to goals
on:
issues:
types: ["opened", "edited", "deleted", "labeled", "unlabeled"]
schedule:
- cron: "0 1 * * 0,2,4,6"
jobs:
sauce-grab:
name: Open Sauced Issue Caching
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Build
run: npm install
- name: Fetch issues
uses: actions/github-script@v1
if: github.repository_owner != 'open-sauced'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require("fs");
async function repoData(response) {
return Promise.all(
response.map(async issue => {
// all goal issues follow the "owner/repo" format
let [owner, name] = issue.title.split("/");
const {data} = await github.repos.get({
owner: owner,
repo: name,
});
return {
full_name: data.full_name,
stargazers_count: data.stargazers_count,
open_issues_count: data.open_issues_count,
forks_count: data.forks_count
}
}),
);
}
// fetch all goal repos
const response = await github.paginate(
github.issues.listForRepo.endpoint.merge({
...context.repo
})
);
// run through responses and print stars repo to json or issue.
const data = await repoData(response);
// create or update the json store
fs.writeFileSync("data.json", JSON.stringify(data, null, 2));
- name: Set up Git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name GitHub
git config user.email [email protected]
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
- name: Commit and push changes
run: |
git add .
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
git commit --author "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" --message "update the goals cache"
git push
fi