Skip to content

Commit

Permalink
Fix #159 add-github-actions-project-1
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnyDev committed Nov 22, 2022
1 parent cfc2f56 commit fd238a6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Github-Actions/Docker_Img_ECR/.github/workflows/aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to production

on:
push:
branches: [ main ]

jobs:

deploy:
name: Build image
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- 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: eu-central-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: nginx-docker
IMAGE_TAG: nginx-v0.0.1
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
5 changes: 5 additions & 0 deletions Github-Actions/Docker_Img_ECR/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx:latest

RUN apt update -y

EXPOSE 8080
26 changes: 26 additions & 0 deletions Github-Actions/Docker_Img_ECR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Github Actions Workflow to build and push docker image to AWS ECR

## Step 1:
Create AWS ECR Repository

`NOTE: make sure to update the variable `**ECR_REPOSITORY: nginx-docker** [aws.yaml](https://github.com/johnbedeir/Github_Actions_Docker_ECR/blob/main/.github/workflows/aws.yaml#:~:text=ECR_REPOSITORY%3A-,nginx%2Ddocker,-IMAGE_TAG%3A%20nginx) ` with the repository name`

## Step 2:
Create github repository and create two Github Secrets using the following names and add your **IAM Access Key and Secret Accress Key**
```
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
```

## Step 3:
Commit the following files you found in this repository

1. Dockerfile
2. .github/workflows.aws.yaml







0 comments on commit fd238a6

Please sign in to comment.