From 6f21a61a1fe77f422422a4a364b69b23076b5233 Mon Sep 17 00:00:00 2001 From: shnamm <96981162+shnamm@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:46:35 +0900 Subject: [PATCH] Create deploy.yml --- .github/workflows/deploy.yml | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..a845f4c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,45 @@ +name: Django CI/CD + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.10.12 # 사용할 Python 버전 선택 + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run Tests + run: | + python manage.py test + + - name: Deploy to AWS CodeDeploy + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_APPLICATION_NAME: autodeploy + AWS_DEPLOYMENT_GROUP: autoDeployGroup + + run: | + aws deploy create-deployment \ + --application-name $AWS_APPLICATION_NAME \ + --deployment-group-name $AWS_DEPLOYMENT_GROUP \ + --file-exists-behavior OVERWRITE \ + --region ap-northeast-2