Community survey #590
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Community survey | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
post-usage-result: | |
needs: usage-survey | |
concurrency: post_result | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/append-survey-responses/ | |
with: | |
name: usage | |
data: ${{ needs.usage-survey.outputs.data }} | |
app_id: ${{ secrets.APP_SURVEY_BOT_ID }} | |
private_key: ${{ secrets.APP_SURVEY_BOT_PEM_CONTENT }} | |
post-star-result: | |
needs: star-survey | |
concurrency: post_result | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/append-survey-responses/ | |
with: | |
name: stars | |
data: ${{ needs.star-survey.outputs.data }} | |
app_id: ${{ secrets.APP_SURVEY_BOT_ID }} | |
private_key: ${{ secrets.APP_SURVEY_BOT_PEM_CONTENT }} | |
usage-survey: | |
runs-on: ubuntu-latest | |
outputs: | |
data: ${{ steps.get-query-results.outputs.result }} | |
steps: | |
- name: Get app token | |
id: get-app-token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{ secrets.APP_PARTICIPANT_ID }} | |
private_key: ${{ secrets.APP_PARTICIPANT_PEM_CONTENT }} | |
- name: Get query results | |
id: get-query-results | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ steps.get-app-token.outputs.token }} | |
script: | | |
const sendQuery = async q => { | |
const url = 'https://api.github.com/search/repositories?q='+q+'&page='; | |
const repos = []; | |
let page = 1; | |
let data; | |
do{ | |
const urlQuery = url+page++; | |
data = (await github.request(urlQuery)).data; | |
if(data.incomplete_results){ | |
queries.push({ | |
query: 'incomplete_results', | |
result: urlQuery | |
}); | |
} | |
repos.push(...data.items); | |
}while(data.items.length); | |
return repos; | |
} | |
const timestamp = JSON.parse(JSON.stringify(new Date())); | |
const queries = []; | |
const excludedRepoOwners = repo => !['AI-Tournaments', 'ChrisAcrobat'].includes(repo.owner.login); | |
const response_total = await sendQuery('topic:AI-Tournaments'); | |
queries.push({ | |
query: 'AI-Tournaments_total', | |
result: response_total.length | |
}); | |
queries.push({ | |
query: 'AI-Tournaments_totalExclusive', | |
result: response_total.filter(excludedRepoOwners).length | |
}); | |
const response_participants = await sendQuery('topic:AI-Tournaments+topic:AI-Tournaments-Participant'); | |
queries.push({ | |
query: 'participants', | |
result: response_participants.filter(repo => !repo.topics.includes('ai-tournaments-retired')).length | |
}); | |
queries.push({ | |
query: 'participantsExclusive', | |
result: response_participants.filter(excludedRepoOwners).filter(repo => !repo.topics.includes('ai-tournaments-retired')).length | |
}); | |
queries.push({ | |
query: 'retiredParticipants', | |
result: response_participants.filter(repo => repo.topics.includes('ai-tournaments-retired')).length | |
}); | |
const response_arenas = await sendQuery('topic:AI-Tournaments+topic:AI-Tournaments-Arena-v1'); | |
queries.push({ | |
query: 'arenas', | |
result: response_arenas.length | |
}); | |
queries.push({ | |
query: 'arenasExclusive', | |
result: response_arenas.filter(excludedRepoOwners).length | |
}); | |
const response_replays = await sendQuery('topic:AI-Tournaments+topic:AI-Tournaments-Replay'); | |
queries.push({ | |
query: 'replays', | |
result: response_replays.length | |
}); | |
queries.push({ | |
query: 'replaysExclusive', | |
result: response_replays.filter(excludedRepoOwners).length | |
}); | |
const response_interfaces = await sendQuery('topic:AI-Tournaments-Interface'); | |
queries.push({ | |
query: 'interfaces', | |
result: response_interfaces.length | |
}); | |
queries.push({ | |
query: 'interfacesExclusive', | |
result: response_interfaces.filter(excludedRepoOwners).length | |
}); | |
return {timestamp, queries}; | |
star-survey: | |
runs-on: ubuntu-latest | |
outputs: | |
data: ${{ steps.get-query-results.outputs.result }} | |
steps: | |
- name: Get app token | |
id: get-app-token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{ secrets.APP_PARTICIPANT_ID }} | |
private_key: ${{ secrets.APP_PARTICIPANT_PEM_CONTENT }} | |
- name: Get query results | |
id: get-query-results | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ steps.get-app-token.outputs.token }} | |
script: | | |
const sendQuery = async q => { | |
const url = 'https://api.github.com/search/repositories?q='+q+'&page='; | |
const repos = []; | |
let page = 1; | |
let data; | |
do{ | |
const urlQuery = url+page++; | |
data = (await github.request(urlQuery)).data; | |
if(data.incomplete_results){ | |
queries.push({ | |
query: 'incomplete_results', | |
result: urlQuery | |
}); | |
} | |
repos.push(...data.items); | |
}while(data.items.length); | |
return repos; | |
} | |
const timestamp = JSON.parse(JSON.stringify(new Date())); | |
const queries = []; | |
const response_stars = await sendQuery('user:AI-Tournaments'); | |
let totalStars = 0; | |
response_stars.filter(r => !r.private).forEach(r => { | |
queries.push({ | |
query: 'stars_'+r.name, | |
result: r.stargazers_count | |
}); | |
totalStars += r.stargazers_count; | |
}); | |
queries.push({ | |
query: 'stars_total', | |
result: totalStars | |
}); | |
return {timestamp, queries}; |