Call APIs #3675
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
# Automatically call APIs | |
name: Call APIs | |
on: | |
release: | |
types: [published] | |
push: | |
tags: | |
- 'v*' | |
schedule: | |
- cron: "9 */2 * * *" | |
workflow_dispatch: | |
watch: | |
types: [started] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# Run on master branch only and Self-ordered start | |
if: | | |
github.ref == 'refs/heads/master' && | |
( (github.event.repository.owner.id == github.event.sender.id) || ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} ) | |
name: Build and call APIs | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: true # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
check-latest: true | |
- name: Install required Python packages | |
run: | | |
pip install requests | |
pip install pynacl | |
- name: Get access token and update refresh token | |
id: get_access_token_step | |
run: | | |
echo `date +"%Y-%m-%d %H:%M:%S"` begin > time.log | |
ms_tokens_output=$(python3 ms_tokens.py ${{ secrets.CONFIG_ID }} ${{ secrets.CONFIG_KEY }} ${{ secrets.REFRESH_TOKEN }} ${{ secrets.GH_TOKEN }} ${{ github.repository }}) | |
echo "$ms_tokens_output" | |
echo "access_token=$(echo "$ms_tokens_output" | sed -n '$p')" >> "$GITHUB_OUTPUT" | |
- name: Call APIs | |
run: | | |
python3 job_call_apis.py ${{steps.get_access_token_step.outputs.access_token}} | |
- name: Commit | |
run: | | |
git config --global user.email [email protected] | |
git config --global user.name Hung | |
git add . | |
git commit -m "Call APIs" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |