Skip to content

Commit

Permalink
Merge pull request #183 from stualan/patch-1
Browse files Browse the repository at this point in the history
Update ReopBot.yml
  • Loading branch information
muxin-web3 authored Dec 7, 2024
2 parents 1816007 + 0b58564 commit 55a4c78
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ReopBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,60 @@ jobs:
git add README.md
git commit -m "Update commit status table"
git push
notify-api:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target' && github.event.pull_request.merged == true || github.event_name == 'push'
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"

- name: Install axios
run: npm install axios

- name: Call API
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const axios = require('axios');
const commit_sha = context.sha;
const { owner, repo } = context.repo;
try {
const { data: commit } = await github.rest.repos.getCommit({
owner,
repo,
ref: commit_sha
});
// Get user details
const { data: user } = await github.rest.users.getByUsername({
username: commit.author.login
});
// Output information
console.log('Commit Author Information:');
console.log('------------------------');
console.log(`Name: ${commit.commit.author.name}`);
console.log(`Email: ${commit.commit.author.email}`);
console.log(`GitHub Username: ${commit.author.login}`);
console.log(`User ID: ${user.id}`);
console.log(`Account Type: ${user.type}`);
console.log(`Created At: ${user.created_at}`);
const response = await axios.get(`https://api.intensivecolearn.ing/api/programs/createByRepo/${owner}/${repo}`);
console.log('API response:', response.data);
const updateUserNotesResp = await axios.get(https://api.intensivecolearn.ing/api/programs/updateStudynotes?owner=${owner}&repo=${repo}&userGitId=${user.id}`);
console.log('updateUserNotesRespAPI response:', updateUserNotesResp.data);
} catch (error) {
console.error('Error calling API:', error.message);
core.setFailed(`Error calling API: ${error.message}`);
}

0 comments on commit 55a4c78

Please sign in to comment.