diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000..3b8af8a --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,37 @@ +name: CD Action +run-name: CD Action in work + +on: # запускать процессы при push и pull_request в ветку main + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + job: # эта часть отвечает за развёртывание приложения + name: Continuous Deployment + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ["21.x"] + steps: + - name: Проверяем код репозитория + uses: actions/checkout@v4 + + - name: Настраиваем Node.js версии ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Устанавливаем SSH ключи + run: | + set -eu + mkdir "$HOME/.ssh" + echo "${{ secrets.DEPLOY_SSH_KEY }}" >> "$HOME/.ssh/id_rsa" + chmod 600 "$HOME/.ssh/id_rsa" + + - name: Отправляем код на сервер + run: scp -i $HOME/.ssh/id_rsa -o StrictHostKeyChecking=no -r /home/runner/work/russian-travel/russian-travel/* ${{ secrets.DEPLOY_SERVER_INFO }} diff --git a/README.md b/README.md index 333357f..b6e0542 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![CD Action](https://github.com/vladosrus/russian-travel/actions/workflows/actions.yml/badge.svg?event=push) # Проект: «Путешествия по России» ### Описание проекта