Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
8dfa251
Ready for deployment
ACompleteNoobSmoke Jan 16, 2024
af9bd0c
ebignore file
ACompleteNoobSmoke Jan 16, 2024
4f295d2
Worked on multiple workflows
ACompleteNoobSmoke Jan 17, 2024
20ccbd4
Worked on multiple workflows
ACompleteNoobSmoke Jan 17, 2024
378d155
Worked on multiple workflows
ACompleteNoobSmoke Jan 17, 2024
1a1908d
Test
ACompleteNoobSmoke Jan 17, 2024
f951e38
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
3bd8cad
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
b5e39bf
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
f8bbc6f
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
01ffd97
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
0110bb4
Fixed Format
ACompleteNoobSmoke Jan 17, 2024
02c0b28
Fixed Format Again
ACompleteNoobSmoke Jan 17, 2024
ebba659
Passed Test
ACompleteNoobSmoke Jan 17, 2024
fab71e0
Merge pull request #1 from ACompleteNoobSmoke/feature/workflows
ACompleteNoobSmoke Jan 17, 2024
c2d226c
Passed Test
ACompleteNoobSmoke Jan 17, 2024
934e557
Merge pull request #2 from ACompleteNoobSmoke/feature/workflows
ACompleteNoobSmoke Jan 17, 2024
291a58e
Passed Test
ACompleteNoobSmoke Jan 17, 2024
4108a04
Merge pull request #3 from ACompleteNoobSmoke/feature/workflows
ACompleteNoobSmoke Jan 17, 2024
0cc3a73
Deploy WF created
ACompleteNoobSmoke Jan 18, 2024
428e2a0
Deploy WF created
ACompleteNoobSmoke Jan 18, 2024
a947410
Deploy WF created
ACompleteNoobSmoke Jan 18, 2024
b320537
Deploy WF created
ACompleteNoobSmoke Jan 18, 2024
5e525f2
Merge pull request #4 from ACompleteNoobSmoke/feature/workflows
ACompleteNoobSmoke Jan 18, 2024
c61a049
Testing
ACompleteNoobSmoke Jan 18, 2024
b2ea579
Testing
ACompleteNoobSmoke Jan 18, 2024
99a7879
Testing
ACompleteNoobSmoke Jan 18, 2024
28e9492
Testing
ACompleteNoobSmoke Jan 18, 2024
4bab885
Changeset
ACompleteNoobSmoke Jan 21, 2024
b83e0d4
New Changes
ACompleteNoobSmoke Jan 21, 2024
c486e5e
Worked on flow
ACompleteNoobSmoke Jan 21, 2024
9fa4d91
Merge pull request #5 from ACompleteNoobSmoke/feature-1
ACompleteNoobSmoke Jan 21, 2024
6d8ae72
Modified Slack Message
ACompleteNoobSmoke Jan 21, 2024
e9040f9
Version Packages
github-actions[bot] Jan 21, 2024
58b1c70
Merge pull request #6 from ACompleteNoobSmoke/changeset-release/main
ACompleteNoobSmoke Jan 21, 2024
fa9ea2c
Modified CD Yaml
ACompleteNoobSmoke Jan 21, 2024
5d0ef48
Merge branch 'main' of https://github.com/ACompleteNoobSmoke/my-nextj…
ACompleteNoobSmoke Jan 21, 2024
885eb6c
Changeset Created
ACompleteNoobSmoke Jan 21, 2024
36bbea8
Version Packages
github-actions[bot] Jan 21, 2024
767cb99
Merge pull request #7 from ACompleteNoobSmoke/changeset-release/main
ACompleteNoobSmoke Jan 21, 2024
f8c785b
Modified Test
ACompleteNoobSmoke Jan 21, 2024
115df36
Modified Test
ACompleteNoobSmoke Jan 21, 2024
b9c2907
Version Packages
github-actions[bot] Jan 21, 2024
e2a0103
Merge pull request #8 from ACompleteNoobSmoke/changeset-release/main
ACompleteNoobSmoke Jan 21, 2024
c4e4c3c
PR Comment WF
ACompleteNoobSmoke Jan 22, 2024
2ec9e2b
Merge branch 'main' of https://github.com/ACompleteNoobSmoke/my-nextj…
ACompleteNoobSmoke Jan 22, 2024
bc01704
Changes something
ACompleteNoobSmoke Jan 22, 2024
6cde0f1
Changes something
ACompleteNoobSmoke Jan 22, 2024
0c38e4e
Fixed Typo
ACompleteNoobSmoke Jan 22, 2024
08a981b
Added symbol
ACompleteNoobSmoke Jan 22, 2024
5cd4570
Made a new flow
ACompleteNoobSmoke Jan 22, 2024
bc14851
Changed a word
ACompleteNoobSmoke Jan 22, 2024
9f55fab
Test
ACompleteNoobSmoke Jan 22, 2024
2a0f790
Test
ACompleteNoobSmoke Jan 23, 2024
b38c716
Test
ACompleteNoobSmoke Jan 23, 2024
357ccf2
Test 2
ACompleteNoobSmoke Jan 23, 2024
4891025
Fixed Pull Request
ACompleteNoobSmoke Jan 23, 2024
e15f02a
Modified Page
ACompleteNoobSmoke Jan 23, 2024
05702c8
Messing with number
ACompleteNoobSmoke Jan 23, 2024
52fc1de
Debug Session
ACompleteNoobSmoke Jan 23, 2024
43d4249
Testing
ACompleteNoobSmoke Jan 23, 2024
6633ce9
Converted to json
ACompleteNoobSmoke Jan 23, 2024
4637b38
Converted to json
ACompleteNoobSmoke Jan 23, 2024
cb67d21
Converted to json
ACompleteNoobSmoke Jan 23, 2024
de17a8b
Converted to json
ACompleteNoobSmoke Jan 23, 2024
cef6b2d
Converted to json
ACompleteNoobSmoke Jan 23, 2024
3f804c2
Converted to json
ACompleteNoobSmoke Jan 23, 2024
fd1bb65
Converted to json!
ACompleteNoobSmoke Jan 23, 2024
e4bbe3c
Fixed Typo
ACompleteNoobSmoke Jan 23, 2024
bafb468
Fixed Typo
ACompleteNoobSmoke Jan 23, 2024
a452388
Made new flow
ACompleteNoobSmoke Jan 25, 2024
83251eb
Made a change
ACompleteNoobSmoke Jan 25, 2024
7c979ff
Made a change
ACompleteNoobSmoke Jan 25, 2024
78e4278
Made new flow
ACompleteNoobSmoke Jan 25, 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.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": { "version": true, "tag": true }
}
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ACompleteNoobSmoke
11 changes: 11 additions & 0 deletions .github/slack/test-failure-slack-payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "* <https://github.com/${{github.repository}}/actions/runs/${{github.run_id }}|${{ github.workflow }} workflow run>* failed."
}
}
]
}
106 changes: 106 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CD

on:
push:
branches: [main]

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

jobs:
create-version-pr-or-release:
name: "Create Version PR/Release"
runs-on: ubuntu-latest
outputs:
should-deploy: ${{steps.changesets.outputs.hasChangesets == 'false'}}
steps:
- name: Checkout Code
uses: actions/checkout@v3
- 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 }}
- name: Print Outputs
run: echo '${{ toJson(steps.changesets.outputs )}}'
- name: Send A Slack Message For Version PR Updates
if: steps.changesets.outputs.pullRequestNumber
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "* <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
- name: Set Release Version
if: steps.changesets.outputs.published == 'true'
id: get-version
run: echo "version=${{ fromJson(steps.changesets.outputs.publishedPackages)[0].version }}" >> $GITHUB_OUTPUT
- name: Send A Slack Message When A New Release Is Created
if: steps.changesets.outputs.published == 'true'
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "* <https://github.com/${{github.repository}}/releases/tag/v${{steps.get-version.outputs.version}}|Version ${{steps.get-version.outputs.version}}>* Released! Deployment Should Be In Progress."
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

run-tests:
name: Run Tests
needs: create-version-pr-or-release
if: needs.create-version-pr-or-release.outputs.should-deploy == 'true'
uses: ./.github/workflows/test.yaml
secrets: inherit

deploy-to-staging:
name: Deploy (Staging)
needs: run-tests
uses: ./.github/workflows/deploy.yaml
secrets: inherit
permissions:
pull-requests: write
with:
aws-env: ${{vars.AWS_EB_STAGING_ENV}}
github-env: "staging"

deploy-to-production:
name: Deploy (Production)
needs: deploy-to-staging
uses: ./.github/workflows/deploy.yaml
secrets: inherit
permissions:
pull-requests: write
with:
aws-env: ${{vars.AWS_EB_PRODUCTION_ENV}}
github-env: "production"
15 changes: 15 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI

on:
pull_request:
branches: [main]

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

jobs:
run-tests:
name: Run Test
uses: ./.github/workflows/test.yaml
secrets: inherit
175 changes: 175 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: Deploy Project

run-name: Deploy

on:
workflow_dispatch:
inputs:
aws-env:
description: "AWS Elastic Beanstalk Environmnet"
required: true
default: "gha-course-staging"
type: string
github-env:
description: "Github Environment"
required: true
default: "staging"
type: string
report-pr:
description: "PR To Add Report Comments To"
type: number
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.github-env }}

jobs:
deploy:
name: Deploy Project
runs-on: ubuntu-latest
permissions:
pull-requests: write
environment:
name: ${{ inputs.github-env }}
url: "http://${{steps.get-env-cname.outputs.aws_cname}}"
steps:
- name: Avoid deploying to production using a non-production env
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: Update Pull Request (Start)
uses: actions/github-script@v6
if: inputs.report-pr
continue-on-error: true
with:
script: |
const comment = `### Deployment in progress...

[You can monitor the progress here.](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})`;

github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.report-pr }},
body: comment
})
- name: Checkout Code
uses: actions/checkout@v3
- 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 }}
- name: Cache
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: Get AWS ENV Name
id: get-env-name
run:
echo "aws_env=$(aws elasticbeanstalk describe-environments --application-name ${{vars.AWS_EB_APP_NAME}}
--environment-name ${{inputs.aws-env}} --query "Environments[0].EnvironmentName"
--output text)" >> $GITHUB_OUTPUT
- name: Get AWS ENV Status
id: get-env-status
run:
echo "aws_status=$(aws elasticbeanstalk describe-environments --application-name ${{vars.AWS_EB_APP_NAME}}
--environment-name ${{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 Environment
if: steps.get-env-name.outputs.aws_env == 'None' || steps.get-env-status.outputs.aws_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_status != 'Terminated'
run: eb deploy ${{inputs.aws-env}}
- name: Get AWS ENV CNAME
id: get-env-cname
run:
echo "aws_cname=$(aws elasticbeanstalk describe-environments --application-name ${{vars.AWS_EB_APP_NAME}}
--environment-name ${{inputs.aws-env}} --query "Environments[0].CNAME"
--output text)" >> $GITHUB_OUTPUT
- name: Send A Slack Message On Failure
id: slack
continue-on-error: true
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":muscle-rocket: Deployment to AWS environment *${{inputs.aws-env}}* using *${{inputs.github-env}}* GitHub Environment was successfull. <http://${{steps.get-env-cname.outputs.aws_cname}}|View Deployment>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Update Pull Request (Start)
uses: actions/github-script@v6
if: success() && inputs.report-pr
with:
script: |
const comment = `### Deployment Completed

[You can view the deployed environment here: ](http://${{ steps.get-env-cname.outputs.aws_cname}})`;

github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.report-pr }},
body: comment
})
- name: Update Pull Request (Start)
uses: actions/github-script@v6
if: failure() && inputs.report-pr
with:
script: |
const comment = `### Deployment Failed

[View Logs](https://github.com/${{ github.repository }}/actions/runs/${{github.run_id}})`;

github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.report-pr }},
body: comment
})
- name: Abort if Cancelled
if: cancelled() && steps.install-eb-cli.conclusion == 'success'
run: eb abort ${{ inputs.aws-env}}
Loading