feat: 종료일 연장 #116
This file contains hidden or 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: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| max-parallel: 4 | |
| matrix: | |
| python-version: [3.9] | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # .env 파일 생성 | |
| - name: Create .env file | |
| uses: SpicyPizza/create-envfile@v1 | |
| with: | |
| envkey_SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
| envkey_DB_NAME: ${{ secrets.DB_NAME }} | |
| envkey_DB_USER: ${{ secrets.DB_USER }} | |
| envkey_DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
| envkey_DB_HOST: ${{ secrets.DB_HOST }} | |
| envkey_SLACK_WEBHOOK_URL_ALARM : ${{ secrets.SLACK_WEBHOOK_URL_ALARM }} | |
| file_name: .env | |
| # 장고 docker 이미지 빌드 | |
| - name: Docker build and push | |
| run: | | |
| docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
| docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ secrets.DOCKER_TAG }} . | |
| docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ secrets.DOCKER_TAG }} | |
| # 라이브러리 설치 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # deploy 폴더에 static 파일 모아주기 | |
| - name: Collect static files to deploy | |
| run: | | |
| python manage.py collectstatic --settings=project.settings.prod | |
| # OCI로 배포 스크립트 전송 | |
| - name: Send scripts to OCI | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.OCI_INSTANCE_HOST }} | |
| username: ${{ secrets.OCI_INSTANCE_USERNAME }} | |
| key: ${{ secrets.OCI_INSTANCE_PRIVATE_KEY }} | |
| port: ${{ secrets.OCI_INSTANCE_PORT }} | |
| source: "./deploy/*" | |
| target: "/srv" | |
| # OCI에서 배포 스크립트 실행 | |
| - name: Deploy to OCI | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.OCI_INSTANCE_HOST }} | |
| username: ${{ secrets.OCI_INSTANCE_USERNAME }} | |
| key: ${{ secrets.OCI_INSTANCE_PRIVATE_KEY }} | |
| port: ${{ secrets.OCI_INSTANCE_PORT }} | |
| script: | | |
| cd /srv/deploy | |
| bash deploy.sh \ | |
| ${{ secrets.DOCKER_USERNAME }} \ | |
| ${{ secrets.DOCKER_PASSWORD }} \ | |
| ${{ secrets.DOCKER_REPOSITORY }} \ | |
| ${{ secrets.DOCKER_TAG }} |