first commint #1
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: 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 - |