Merge branch 'main' of https://github.com/Mutsa-Hackerton-11th/back #14
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
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: Install AWS CLI | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y awscli | |
- name: Configure AWS CLI | |
run: | | |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws configure set region ap-northeast-2 | |
- name: Create mutsa.zip | |
run: | | |
zip -r mutsa.zip ./* | |
- name: Upload to S3 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
set -x | |
aws s3 cp mutsa.zip s3://mutsa-s3-bucket/ | |
- 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 \ | |
--s3-location bucket=mutsa-s3-bucket,bundleType=zip,key=mutsa.zip \ | |
--region ap-northeast-2 |