This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
Return Data from JavaScript Function #1129
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: Return Data from JavaScript Function | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0,8,16 * * *" | |
jobs: | |
call_api_job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js and NPM | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Install Dependencies | |
run: | | |
npm install axios | |
working-directory: ${{ github.workspace }} | |
- name: Run JavaScript File | |
id: fetchIssues | |
run: | | |
data=$(node -e "const fetchIssues = require('./fetchIssues'); async function main() { try { const data = await fetchIssues(); console.log(JSON.stringify(data));} catch (error) { console.error('Error retrieving data:', error);}}; main()") | |
cp issues.json issues.json.res | |
echo "$data" > issues.json | |
- name: Push into Git | |
run: |- | |
if ! diff -q issues.json{,.res} > /dev/null | |
then | |
git config --global user.email "[email protected]" | |
git config --global user.name "ARK Builders Bot" | |
git add issues.json | |
git commit -m "Indexing GitHub issues" | |
git push | |
fi |