.github/workflows/check.yml #6
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: Check and Deploy Discord Bot | |
on: | |
schedule: | |
- cron: '*/10 * * * *' | |
workflow_dispatch: | |
jobs: | |
check-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Check running jobs | |
id: check_jobs | |
run: | | |
# Получаем список запущенных рабочих процессов | |
RUNNING_JOBS=$(gh api /repos/${{ github.repository }}/actions/runs \ | |
--jq '.workflow_runs[] | select(.name=="Deploy Discord Bot" and .status=="in_progress") | .id') | |
if [ -z "$RUNNING_JOBS" ]; then | |
echo "Deployment is not running." | |
echo "needs_deploy=true" >> $GITHUB_ENV | |
else | |
echo "Deployment is already running." | |
echo "needs_deploy=false" >> $GITHUB_ENV | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy | |
if: env.needs_deploy == 'true' | |
uses: ./.github/workflows/deploy.yml |