-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #159 add-github-actions-project-1
- Loading branch information
JohnyDev
committed
Nov 22, 2022
1 parent
cfc2f56
commit fd238a6
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM nginx:latest | ||
|
||
RUN apt update -y | ||
|
||
EXPOSE 8080 |
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
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 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|