chore | sprint0 | FRB-133 | EC2 배포용 워크플로우 설정 | 조수빈 #5
Workflow file for this run
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: Build and Deploy to EC2 with Docker Compose | |
| on: | |
| push: | |
| branches: | |
| - chore/deploy-to-ec2 | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| # strategy: | |
| # matrix: | |
| # node-version: [18] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # - name: Set up Node ${{ matrix.node-version }} | |
| # uses: actions/setup-node@v3 | |
| # with: | |
| # node-version: ${{ matrix.node-version }} | |
| # - name: Cache node_modules | |
| # uses: actions/cache@v3 | |
| # with: | |
| # path: | | |
| # **/node_modules | |
| # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| # restore-keys: ${{ runner.os }}-node- | |
| # - name: Install dependencies | |
| # run: npm ci | |
| # - name: Build | |
| # run: npm run build | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| - name: Build and push image to ECR | |
| env: | |
| ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }} | |
| ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} | |
| IMAGE_TAG: frontend-latest | |
| run: | | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |