task1 #131
This file contains hidden or 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: Trademan CI/CD | |
| on: [push] | |
| env: | |
| BOT_TAG: holohup/trademan_bot:latest | |
| BASE_TAG: holohup/trademan_base:latest | |
| jobs: | |
| code_tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Python Setup | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| cache: 'pip' | |
| cache-dependency-path: '**/*requirements*.txt' | |
| - name: Installing dependencies and testing scripts | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements-tests.txt | |
| - name: Flake8 tests | |
| run: python -m flake8 | |
| - name: Unit tests | |
| run: pytest | |
| build_image_and_push_to_docker_hub: | |
| name: Build and Push Docker image to Docker Hub | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| runs-on: self-hosted | |
| needs: code_tests | |
| steps: | |
| - name: check out repo | |
| uses: actions/checkout@v2 | |
| - name: log in to docker | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: build and push bot to DockerHub | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: bot | |
| push: true | |
| tags: ${{ env.BOT_TAG }} | |
| - name: build and push base to DockerHub | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: trademan | |
| push: true | |
| tags: ${{ env.BASE_TAG }} | |
| send_message: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' | |
| needs: build_image_and_push_to_docker_hub | |
| steps: | |
| - name: send message | |
| uses: appleboy/telegram-action@master | |
| with: | |
| to: ${{ secrets.TELEGRAM_CHAT_ID }} | |
| token: ${{ secrets.TELEGRAM_TOKEN }} | |
| message: ${{ github.workflow }} успешно выполнен! |