fix: 가동 브랜치 변경 (#6) #2
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: AWS ECR push & deploy k8s | |
on: | |
push: | |
branches: [ Cicd/2-add-script-file ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v2 | |
- name: Check Node v | |
run: node -v | |
- name: AWS ECR push & deploy k8s | |
run: | | |
npm install | |
npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: \${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: \${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: $AWS_REGION | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Get image tag(verion) | |
id: image | |
run: | | |
VERSION=\$(echo \${{ github.sha }} | cut -c1-8) | |
echo VERSION=\$VERSION | |
echo "::set-output name=version::\$VERSION" | |
- name: Build, tag, and push image to Amazon ECR | |
id: image-info | |
env: | |
ECR_REGISTRY: \${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: demo-moreview-backend | |
IMAGE_TAG: \${{ steps.image.outputs.version }} | |
run: | | |
echo "::set-output name=ecr_repository::\$ECR_REPOSITORY" | |
echo "::set-output name=image_tag::\$IMAGE_TAG" | |
docker build -t \$ECR_REGISTRY/\$ECR_REPOSITORY:\$IMAGE_TAG . | |
docker push \$ECR_REGISTRY/\$ECR_REPOSITORY:\$IMAGE_TAG |