From db7e8c0cf9590dba10110a60c61ec340a63fdb4c Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:21:23 +0400 Subject: [PATCH 1/6] cd --- .github/workflows/cd.yml | 12 ++++++++++++ .vscode/settings.json | 7 +++++++ requirements.txt | 1 - 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd.yml create mode 100644 .vscode/settings.json diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..7a6885b --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,12 @@ +name: Continuous Deployment +on: push + +jobs: + hello-gh-actions: + name: Hello GitHub Actions + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Run Tests + run: echo "RUNNING TESTS!" \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6ee269c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#233120", + "titleBar.activeBackground": "#31452D", + "titleBar.activeForeground": "#FAFBF9" + } +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index cb4ae7b..028a636 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ Django>=3.1.7,<3.2 uWSGI>=2.0.19,<2.1 - flake8>=3.9.0,<3.10 From e28f94f08af09d0cfde6a9893410bc50e3b54d04 Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:25:19 +0400 Subject: [PATCH 2/6] Django run --- .github/workflows/cd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 7a6885b..74d6dd7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -2,11 +2,11 @@ name: Continuous Deployment on: push jobs: - hello-gh-actions: - name: Hello GitHub Actions - runs-on: ubuntu-20.04 + test: + name: Test + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - - name: Run Tests - run: echo "RUNNING TESTS!" \ No newline at end of file + - name: Test + run: docker-compose run --rm app sh -c "python manage.py test" \ No newline at end of file From 20c416af0532be00e6c71e3002a141eb7089d6ba Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:30:12 +0400 Subject: [PATCH 3/6] Django run two jobs --- .github/workflows/cd.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 74d6dd7..b930f1d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,5 +1,9 @@ name: Continuous Deployment -on: push +on: + push: + branches: + - main + - production jobs: test: @@ -9,4 +13,13 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Test - run: docker-compose run --rm app sh -c "python manage.py test" \ No newline at end of file + run: docker-compose run --rm app sh -c "python manage.py test" + + lint: + name: Lint + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Lint + run: docker-compose run --rm app sh -c "flake8" \ No newline at end of file From 0e414f30c3020a416f8ddb02d69cac2c772b4d4b Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:33:23 +0400 Subject: [PATCH 4/6] Run 4 jobs --- .github/workflows/cd.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b930f1d..dbe8a72 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -4,6 +4,9 @@ on: branches: - main - production + + pull_request: [] + jobs: test: @@ -22,4 +25,27 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Lint - run: docker-compose run --rm app sh -c "flake8" \ No newline at end of file + run: docker-compose run --rm app sh -c "flake8" + + deploy-staging: + name: Deploy to Staging + runs-on: ubuntu-20.04 + needs: [test, lint] + if: github.ref == 'refs/heads/main' + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Deploy to Staging + run: echo "Deploy to STAGING code here" + + + deploy-prod: + name: Deploy to Production + runs-on: ubuntu-20.04 + needs: [test, lint] + if: github.ref == 'refs/heads/production' + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Deploy to Prod + run: echo "Deploy to PRODUCTION code here" From 2b0cc077ecac47a160d774ab07fc79a86f559f2a Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:37:32 +0400 Subject: [PATCH 5/6] Run 4 jobs --- app/home/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/home/views.py b/app/home/views.py index ea1f535..821d873 100644 --- a/app/home/views.py +++ b/app/home/views.py @@ -3,4 +3,5 @@ def index(request): """Render index page.""" + return None return render(request, 'home/index.html') From 8e487609175d5f23f74ceb819e4d820e57d96e36 Mon Sep 17 00:00:00 2001 From: Mehdi Raza Jaffri Date: Thu, 27 Jan 2022 12:40:39 +0400 Subject: [PATCH 6/6] Fixed the problem --- app/home/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/home/views.py b/app/home/views.py index 821d873..3311ff9 100644 --- a/app/home/views.py +++ b/app/home/views.py @@ -3,5 +3,5 @@ def index(request): """Render index page.""" - return None + # return None return render(request, 'home/index.html')