forked from udacity/cd12354-Movie-Picture-Pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit Signed-off-by: tunguyen4585 <n.van.tu0909@gmail.com>
- Loading branch information
1 parent
c38cdd2
commit 67f1602
Showing
9 changed files
with
1,473 additions
and
34 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,32 @@ | ||
name: 'Backend setup' | ||
description: 'Setup python, caches and installs pip dependencies' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
id: setup_python | ||
with: | ||
python-version: '3.10' | ||
cache: 'pipenv' | ||
- run: echo 'Cache hit ${{ steps.setup_python.outputs.cache-hit }}' # true if cache-hit occurred on the primary key | ||
shell: bash | ||
|
||
- name: Install pipenv | ||
working-directory: backend | ||
run: pip install pipenv | ||
shell: bash | ||
|
||
# - name: Cache Pipenv dependencies | ||
# uses: actions/cache@v3 | ||
# with: | ||
# path: ~/.local/share/virtualenvs | ||
# key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-pipenv- | ||
|
||
- name: Install Dependencies | ||
working-directory: backend | ||
run: pipenv install --dev | ||
shell: bash |
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,37 @@ | ||
name: 'Frontend setup' | ||
description: 'Sets up Node.js, caches and installs npm dependencies' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
cache-dependency-path: ./frontend/package-lock.json | ||
|
||
# - name: Cache node modules | ||
# id: cache-npm # use later to check if cache hit | ||
# uses: actions/cache@v3 | ||
# env: | ||
# cache-name: cache-node-modules | ||
# with: | ||
# # npm cache files are stored in `~/.npm` on Linux/macOS | ||
# path: ~/.npm | ||
# key: ${{ runner.os }}-node-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}-node-${{ env.cache-name }}- | ||
# ${{ runner.os }}-node- | ||
|
||
# - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
# name: List the state of node modules | ||
# continue-on-error: true | ||
# working-directory: ./frontend | ||
# run: npm list | ||
# shell: bash | ||
|
||
- name: Install the dependencies. | ||
working-directory: ./frontend | ||
run: npm ci --loglevel=error --no-fund | ||
shell: bash |
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,98 @@ | ||
name: Backend Continuous Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
Linting: | ||
runs-on: ubuntu-latest | ||
environment: Devlopmnet Environment | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Rependencies | ||
working-directory: starter/backend | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
pip install flake8 | ||
- name: Checkout Run Lint | ||
run: cd starter/backend && pipenv run lint | ||
|
||
Test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Python 3 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Dependencies | ||
working-directory: starter/backend | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
pip install flake8 | ||
- name: Test | ||
run: cd starter/backend && pipenv install pytest && pipenv run test | ||
|
||
|
||
Build: | ||
needs: [Linting, Test] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
|
||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
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: Login to Amazon | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build and Push Docker Image | ||
working-directory: starter/backend | ||
env: | ||
IMAGE_TAG: latest | ||
REPO_NAME: backend | ||
run: | | ||
docker build --build-arg=REACT_APP_MOVIE_API_URL=http://localhost:5000 --tag 669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG . | ||
docker push 669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG | ||
- name: Update Kubeconfig | ||
run: | ||
aws eks update-kubeconfig --name udacity-project4 --region us-east-1 | ||
|
||
- name: Deploy Docker Image to Amazon EKS | ||
working-directory: starter/backend/k8s | ||
env: | ||
IMAGE_TAG: latest | ||
REPO_NAME: backend | ||
run: | | ||
aws eks update-kubeconfig --name udacity-project4 --region us-east-1 | ||
kustomize edit set image backend=669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG | ||
kustomize build | kubectl apply -f - |
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,67 @@ | ||
name: Backend Continuous Integration | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
Linting: | ||
runs-on: ubuntu-latest | ||
environment: Devlopmnet Environment | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Dependencies | ||
working-directory: starter/backend | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
pip install flake8 | ||
- name: Checkout Run Lint | ||
run: cd starter/backend && pipenv run lint | ||
|
||
Test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Python 3 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Dependencies | ||
working-directory: starter/backend | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pipenv | ||
pip install flake8 | ||
- name: Test | ||
run: cd starter/backend && pipenv install pytest && pipenv run test | ||
|
||
|
||
Build: | ||
needs: [Linting, Test] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build Docker Image | ||
run: | | ||
cd starter/backend | ||
docker build --tag mp-backend:latest . |
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,107 @@ | ||
name: Frontend Continuous Deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
Linting: | ||
runs-on: ubuntu-latest | ||
environment: Devlopmnet Environment | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
cache-dependency-path: starter/frontend/package-lock.json | ||
|
||
- name: Install Dependencies | ||
working-directory: starter/frontend | ||
run: npm ci | ||
|
||
- name: Checkout Run Lint | ||
run: cd starter/frontend && npm run lint | ||
|
||
Test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
cache-dependency-path: starter/frontend/package-lock.json | ||
|
||
- name: Install Dependencies | ||
working-directory: starter/frontend | ||
run: npm ci | ||
|
||
- name: Test | ||
run: cd starter/frontend && npm run test | ||
|
||
|
||
|
||
Build: | ||
needs: [Linting, Test] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check the Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'npm' | ||
cache-dependency-path: starter/frontend/package-lock.json | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
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: Login to Amazon | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
|
||
|
||
- name: Build and Push Docker Image | ||
working-directory: starter/frontend | ||
env: | ||
IMAGE_TAG: latest | ||
REPO_NAME: frontend | ||
run: | | ||
docker build --build-arg=REACT_APP_MOVIE_API_URL=http://localhost:5000 --tag 669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG . | ||
docker push 669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG | ||
|
||
- name: Configure Kubeconfig | ||
run: | ||
aws eks update-kubeconfig --name udacity-project4 --region us-east-1 | ||
|
||
|
||
- name: Deploy Docker Image to Amazon EKS | ||
working-directory: starter/frontend/k8s | ||
env: | ||
IMAGE_TAG: latest | ||
REPO_NAME: frontend | ||
run: | | ||
kustomize edit set image frontend=669172573612.dkr.ecr.us-east-1.amazonaws.com/$REPO_NAME:$IMAGE_TAG | ||
kustomize build | kubectl apply -f - |
Oops, something went wrong.