-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
56 lines (51 loc) · 1.98 KB
/
action.yaml
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
name: "Query developer statistics"
description: "Query developer statistics from GitHub, and upload compressed JSON bundle as an artifact."
inputs:
repos:
description: >-
The GitHub repositories to query for devstats; a string
containing a YAML list, e.g. '[username/reponame1, username/reponame2]'
required: true
artifact-name:
description: "Name given to the uploaded artifact (zip file of all devstats bundles)"
required: true
token:
description: "A Github Personal Access Token with `public_repo` permission"
default: ${{ github.token }}
timezone:
description: "Timezone for bundle date"
default: UTC
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install devstats (main)
shell: bash
run: |
pip install git+https://github.com/scientific-python/devstats.git
- name: Download data
env:
REPOS: ${{ inputs.repos }}
GRAPH_API_KEY: ${{ inputs.token }}
TZ: ${{ inputs.timezone }}
shell: bash
run: |
REPOS_JSON=$(python -c "import yaml, json, sys; print(json.dumps(yaml.safe_load(sys.argv[1].replace(r'\\n', ''))))" "$REPOS")
REPOS_JSON_SPLIT=$(echo $REPOS_JSON | jq -c '.[] | split("/") | {org: .[0], repo: .[1]}')
for ORG_REPO in $REPOS_JSON_SPLIT; do
ORG=$(echo $ORG_REPO | jq -r ".org")
REPO=$(echo $ORG_REPO | jq -r ".repo")
FILENAME="$(TZ=$TZ date +"%Y-%m-%d")-devstats-$REPO.tar.xz"
echo -e "Querying [$ORG/$REPO]...\n" >> $GITHUB_STEP_SUMMARY
devstats query $ORG $REPO >> $GITHUB_STEP_SUMMARY
echo -e "\nCreating archive [$FILENAME]...\n" >> $GITHUB_STEP_SUMMARY
(cd devstats-data; tar cfJ $FILENAME *_issues.json *_PRs.json)
done
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: "devstats-data/*.tar.xz"