Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create workflow #55

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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.2
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
2 changes: 1 addition & 1 deletion Chapter02/kubia/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ console.log("Kubia server starting...");
var handler = function(request, response) {
console.log("Received request from " + request.connection.remoteAddress);
response.writeHead(200);
response.end("You've hit " + os.hostname() + "\n");
response.end("Hi Im Prashant and you have hit " + os.hostname() + "\n");
};

var www = http.createServer(handler);
Expand Down