Update main.yml #6
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: Deploy to ECR | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} | |
AWS_REGION: us-east-1 | |
- name: Build, test, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: clo835-week3 | |
IMAGE_TAG: v1.1 | |
run: | | |
cd Chapter02/kubia/ | |
ls -ltra | |
# Docker build | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
# Unit test | |
docker run -d -p 80:8080 --name nodeapp $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker ps | |
echo "Pause for 10 seconds to let container start" | |
sleep 10 | |
curl localhost -vvv | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |