Workflow file for this run
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 CD | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'starter/frontend/**' | ||
workflow_dispatch: | ||
jobs: | ||
npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Configure AWS Credentials | ||
run: | | ||
echo "[default]" > ~/.aws/credentials | ||
echo "aws_access_key_id=${{ secrets.ACCESS_KEY }}" >> ~/.aws/credentials | ||
echo "aws_secret_access_key=${{ secrets.SECRET_KEY }}" >> ~/.aws/credentials | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: | | ||
cd starter/frontend | ||
npm ci | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: | | ||
cd starter/frontend | ||
npm install | ||
- name: Install ESLint | ||
run: | | ||
cd starter/frontend | ||
npm install eslint --save-dev | ||
- name: Lint Code | ||
run: | | ||
cd starter/frontend | ||
npm run lint | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: | | ||
cd starter/frontend | ||
npm ci | ||
- name: Run Tests | ||
run: | | ||
cd starter/frontend | ||
npm test | ||
- name: Simulate running tests | ||
run: | | ||
cd starter/frontend | ||
CI=true npm test | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: [lint, test] # This ensures 'build' only runs if 'lint' and 'test' jobs succeed | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: | | ||
cd starter/frontend | ||
npm ci | ||
- name: Build Docker Image | ||
run: | | ||
cd starter/frontend | ||
docker build --build-arg=REACT_APP_MOVIE_API_URL=http://localhost:5000 --tag=837520400973.dkr.ecr.us-east-1.amazonaws.com/frontend:latest . | ||
- name: Push Image to ECR Docker | ||
run: | | ||
cd starter/frontend | ||
docker push 837520400973.dkr.ecr.us-east-1.amazonaws.com/frontend:latest | ||
- name: Update Kube-config | ||
run: | | ||
cd starter/frontend/k8s | ||
aws eks update-kubeconfig | ||
- name: Deploy to EKS | ||
run: | | ||
cd starter/frontend/k8s | ||
kustomize edit set image frontend=837520400973.dkr.ecr.us-east-1.amazonaws.com/frontend:0.1 | ||
- name: Apply the manifests to the cluster | ||
run: | | ||
cd starter/frontend/k8s | ||
kustomize build | kubectl apply -f - |