Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
63de058
Match course code
Kurmanbek10 Sep 28, 2024
2c7acd4
setup elastic beanstalk
Kurmanbek10 Sep 28, 2024
a8b9d88
CI Workflow
Kurmanbek10 Oct 3, 2024
6d6a339
Slack on Failure
Kurmanbek10 Oct 3, 2024
5f3cb44
Fixed Code Typos
Kurmanbek10 Oct 3, 2024
7d549f0
Test Webhook Url
Kurmanbek10 Oct 3, 2024
848ad25
For testing Slack Changed secrets to variables
Kurmanbek10 Oct 3, 2024
07aad1a
slack test v1.10
Kurmanbek10 Oct 3, 2024
a651bc7
Typo check
Kurmanbek10 Oct 3, 2024
694b8dd
Skipping Formatting Test
Kurmanbek10 Oct 3, 2024
c021167
Flagsmith key added to secrets
Kurmanbek10 Oct 3, 2024
0327fa4
updated packages
Kurmanbek10 Oct 3, 2024
4524653
flagsmith key bug
Kurmanbek10 Oct 4, 2024
64e42cf
Included format checking previously disabled
Kurmanbek10 Oct 4, 2024
67a0e06
Ran Format Prettier Before push
Kurmanbek10 Oct 4, 2024
f4a2850
On Workflow Call - Pull Request
Kurmanbek10 Oct 4, 2024
22925c6
Update page.tsx
kurmanbek13 Oct 4, 2024
f008d42
Merge pull request #10 from github-actions-1/kurmanbek13-patch-1.1
Kurmanbek10 Oct 6, 2024
10b4f88
Cache Playwright
Kurmanbek10 Oct 6, 2024
e0aae7c
Merge branch 'main' of github.com:github-actions-1/nextjs-starter
Kurmanbek10 Oct 6, 2024
caa2768
Fix Prettier formatting issues
Kurmanbek10 Oct 6, 2024
091e558
Deployment automation
Kurmanbek10 Oct 6, 2024
226ab51
Deployment workflow fixes
Kurmanbek10 Oct 6, 2024
fe741c8
Building app, ENV key for FlagSmith is added:
Kurmanbek10 Oct 6, 2024
229b945
Fixed avoiding if it's a non production enviroment
Kurmanbek10 Oct 6, 2024
6728547
--platform was fixed ""
Kurmanbek10 Oct 6, 2024
5d7d25b
new text
Kurmanbek10 Oct 6, 2024
254b3cf
Added changeset
Kurmanbek10 Oct 6, 2024
4a43e79
Updated Text
Kurmanbek10 Oct 6, 2024
1bec961
Added CD Workflow
Kurmanbek10 Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
12 changes: 12 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.3/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": {"version": true, "tag": true}
}
5 changes: 5 additions & 0 deletions .changeset/nine-trains-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"next-1": patch
---

Updated text
42 changes: 42 additions & 0 deletions .ebignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage
/test-results
/playwright-report

# next.js
/out/
.swc

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* @kurmanbek10
*.js @kurmanbek10
*.ts @kurmanbek10
*.tsx @kurmanbek10
/e2e/ @kurmanbek13
50 changes: 50 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CD
on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
create-version-pr-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node Environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Create Version PR or Github Release
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset tag
env:
GITHUB_TOKEN: ${{ secrets.CHANGESETS_TOKEN }}
- run: echo '${{ toJson(steps.changesets.outputs) }}'
- name: Send a Slack Message to Version PR Update
if: steps.changesets.outputs.pullRequestNumber
id: slack
uses: slackapi/slack-github-action@v1.27.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: *<https://github.com/${{github.repository}}/pull/${{steps.changesets.outputs.pullRequestNumber}}|Version Pull Request>* Was updated. Review it and merge it to create a new release and deployment."
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: CI
on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
run-tests:
uses: ./.github/workflows/test.yaml
secrets: inherit
114 changes: 114 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Deploy
on:
workflow_dispatch:
inputs:
aws-env:
description: "AWS Elastic Beanstalk Environment"
required: true
default: "gha-course-staging"
type: string
github-env:
description: "Github Environment"
required: true
default: "staging"
type: string
workflow_call:
inputs:
aws-env:
description: "AWS Elastic Beanstalk Environment"
required: true
default: "gha-course-staging"
type: string
github-env:
description: "Github Environment"
required: true
default: "staging"
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.aws-env }}-${{ inputs.github-env }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.github-env }}
url: "http://${{ steps.get-env-cname.outputs.aws_env_cname }}"
steps:
- name: Avoid deploying to production using a non production environment
if: inputs.aws-env == vars.AWS_EB_PRODUCTION_ENV && inputs.github-env != 'production'
run: |
echo "::error:: Cannot deploy to production using a non production environment"
exit 1
- 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-region: ${{ vars.AWS_REGION }}
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node Environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Build App
run: npm run build
env:
FLAGSMITH_KEY: ${{ secrets.FLAGSMITH_KEY }}
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- name: Install EB CLI
id: install-eb-cli
run: pip install awsebcli
- name: Cache EB CLI
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-ebcli
- name: Get AWS ENV Name
id: get-env-name
run: echo "aws_env=$(aws elasticbeanstalk describe-environments --application-name ${{ vars.AWS_EB_APP_NAME }} --environment-names ${{ inputs.aws-env }} --query "Environments[0].EnvironmentName" --output text)" >> $GITHUB_OUTPUT
- name: Get AWS ENV Status
id: get-env-status
run: echo "aws_env_status=$(aws elasticbeanstalk describe-environments --application-name ${{ vars.AWS_EB_APP_NAME }} --environment-names ${{ inputs.aws-env }} --query "Environments[0].Status" --output text)" >> $GITHUB_OUTPUT
- name: Initialize EB
run: eb init ${{ vars.AWS_EB_APP_NAME }} --platform "${{ vars.AWS_EB_PLATFORM }}" --region ${{ vars.AWS_REGION }}
- name: Create a New Evironment
if: steps.get-env-name.outputs.aws_env == 'None' || steps.get-env-status.outputs.aws_env_status == 'Terminated'
run: eb create ${{ inputs.aws-env }} --instance-types ${{ vars.AWS_EB_ENV_INSTANCE_TYPES }} --cname ${{ inputs.aws-env }} --envvars FLAGSMITH_KEY=${{ secrets.FLAGSMITH_KEY }}
- name: Deploy if Environment Exists
if: steps.get-env-name.outputs.aws_env == inputs.aws-env && steps.get-env-status.outputs.aws_env_status != 'Terminated'
run: eb deploy ${{ inputs.aws-env }}
- name: Get AWS ENV CNAME
id: get-env-cname
run: echo "aws_env_cname=$(aws elasticbeanstalk describe-environments --application-name ${{ vars.AWS_EB_APP_NAME }} --environment-names ${{ inputs.aws-env }} --query "Environments[0].CNAME" --output text)" >> $GITHUB_OUTPUT
- name: Send a Slack Message on Failure
id: slack
uses: slackapi/slack-github-action@v1.27.0
if: always()
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rocket: Deployment to AWS environment *${{ inputs.aws-env }}* using *${{ inputs.github-env }}* Github environment was successfull. <http://${{ steps.get-env-cname.outputs.aws_env_cname }}|View Deployments>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Abort if Cancelled
if: cancelled() && steps.install-eb-cli.conclusion == 'success'
run: eb abort ${{ inputs.aws-env }}
93 changes: 93 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Test
on:
workflow_call:

jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node Environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Check and fix Formatting Errors
run: |
npm run format -- --write
npm run format
- name: Check for ESLint Errors
run: npm run lint
- name: Check for Type Errors
run: npm run typecheck
- name: Build Project
run: npm run build
env:
FLAGSMITH_KEY: ${{ secrets.FLAGSMITH_KEY }}
- uses: actions/upload-artifact@v4
with:
name: build
path: .next/
- name: Run Unit Tests
run: npm run test
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage/
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Store Playwright's Version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright's Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Chache Playwright Browsers
uses: actions/cache@v4
id: cache-playwright
with:
path: ~/.cache/ms-playwright
key: playwright-browser-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Playwright Browsers
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Run E2E Tests
run: npm run test:e2e
env:
FLAGSMITH_KEY: ${{ secrets.FLAGSMITH_KEY }}

- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
- name: Send a Slack Message on Failure
id: slack
uses: slackapi/slack-github-action@v1.27.0
if: failure()
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🛑 *<https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}|${{ github.workflow }} workflow run>* failed."
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
test-webhook-url-secret:
runs-on: ubuntu-latest
steps:
- name: Check Slack Webhook Url
run: echo "Webhook URL is ${{ secrets.SLACK_WEBHOOK_URL }}"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"editor.formatOnSave": true,
"yaml.format.enable": true,
"editor.fontSize": 18,
"window.zoomLevel": 3.5,
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": false,
// "editor.hover.enabled": false,
"gitlens.currentLine.enabled": false,
"terminal.integrated.fontSize": 18,
"terminal.integrated.fontWeight": "500",
"terminal.integrated.fontWeightBold": "600",
"gitlens.codeLens.enabled": false
}
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm run start -- -p $PORT
Loading