Manage users #619
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 add and delete users | |
name: Manage users | |
on: | |
release: | |
types: [published] | |
push: | |
tags: | |
- 'v*' | |
schedule: | |
- cron: "18 8,16 * * *" | |
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 manage users | |
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: Add and delete users | |
run: | | |
python3 job_manage_users.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 "Add and delete users" -a | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |