-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CI-CD workflow to lint, test & automatically deploy on remote s…
…erver
- Loading branch information
Showing
3 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Useful links | ||
# - https://docs.github.com/en/actions/learn-github-actions/variables | ||
# - https://github.com/dokku/github-action/issues/8 | ||
# | ||
|
||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Run linting and tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install poetry | ||
make install | ||
- name: Run linter | ||
run: make lint | ||
|
||
- name: Run tests | ||
run: make test | ||
|
||
- name: Code Climate Coverage Action | ||
uses: paambaati/[email protected] | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
with: | ||
coverageCommand: make coverage_xml | ||
|
||
deploy: | ||
name: Deploy app on Dokku Server | ||
runs-on: ubuntu-latest | ||
needs: test | ||
if: ${{ needs.test.result == 'success' }} | ||
steps: | ||
- name: Clone repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to Dokku | ||
uses: dokku/github-action@master | ||
with: | ||
git_push_flags: '--force' | ||
branch: main | ||
git_remote_url: ssh://${{ secrets.DOKKU_USERNAME }}@${{ secrets.DOKKU_SERVER_IP }}:22/~/${{ secrets.DOKKU_APP_NAME }} | ||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
notify: | ||
name: Send Slack Notification | ||
runs-on: ubuntu-latest | ||
needs: [test, deploy] | ||
if: always() | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Slack Notification on Success | ||
if: ${{ needs.test.result == 'success' && needs.deploy.result == 'success' }} | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_ICON: https://www.google.com/s2/favicons?domain=github.com&sz=128 | ||
SLACK_COLOR: "good" | ||
SLACK_USERNAME: "GitHub Actions" | ||
SLACK_TITLE: > | ||
🟢 CI/CD Pipeline Succeeded for "${{ github.repository }}" project | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
|
||
- name: Slack Notification on Failure | ||
if: ${{ needs.test.result == 'failure' || needs.deploy.result == 'failure' }} | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_ICON: https://www.google.com/s2/favicons?domain=github.com&sz=128 | ||
SLACK_COLOR: "danger" | ||
SLACK_USERNAME: "GitHub Actions" | ||
SLACK_TITLE: > | ||
❌ CI/CD Workflow Failed for "${{ github.repository }}" project | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
### Hexlet tests and linter status: | ||
[![Actions Status](https://github.com/n8creator/python-project-lvl4/workflows/hexlet-check/badge.svg)](https://github.com/n8creator/python-project-lvl4/actions) | ||
[![Actions Status](https://github.com/n8creator/python-project-lvl4/workflows/hexlet-check/badge.svg)](https://github.com/n8creator/python-project-lvl4/actions) | ||
[![Github Actions Status](https://github.com/n8creator/python-project-lvl4/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/n8creator/python-project-lvl4/actions) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/07700d46e12b1094c627/maintainability)](https://codeclimate.com/github/n8creator/python-project-lvl4/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/07700d46e12b1094c627/test_coverage)](https://codeclimate.com/github/n8creator/python-project-lvl4/test_coverage) |