Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasodonnell committed Aug 4, 2023
0 parents commit a00b2b8
Show file tree
Hide file tree
Showing 37 changed files with 5,441 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["next/babel"]
}
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# next
.next
.vercel

# build
dist

# node
node_modules
npm-debug.log*

# docker
.env
docker-compose.override.yml

# config
config
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# app
TZ=America/New_York
RS_URL=http://restreamer:8080

# restreamer
RS_USERNAME=admin
RS_PASSWORD=admin
51 changes: 51 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"extends": [
"next/core-web-vitals",
"prettier"
],
"plugins": [
"import",
"perfectionist",
"prettier"
],
"rules": {
"arrow-parens": [ "error", "as-needed" ],
"comma-dangle": [ "error", {
"arrays": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
"imports": "always-multiline",
"objects": "always-multiline"
} ],
"import/newline-after-import": [ "error", { "count": 1 } ],
"import/no-anonymous-default-export": "off",
"import/no-cycle": 1,
"import/no-self-import": 1,
"import/order": [ "error", {
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
"newlines-between": "always",
"groups": [
"builtin",
"external",
"parent",
"sibling",
"index"
]
}],
"no-unused-expressions": 2,
"object-curly-spacing": [ "error", "always" ],
"perfectionist/sort-objects": [
"error",
{
"type": "natural",
"order": "asc"
}
],
"prettier/prettier": ["error"],
"quotes": [ "error", "single", { "allowTemplateLiterals": true } ],
"semi": [ "error", "never" ]
}
}
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build

on:
workflow_call:
outputs:
current_version:
description: 'Current version in package.json'
value: ${{ jobs.build.outputs.current_version }}
previous_version:
description: 'Previous version according to git tags'
value: ${{ jobs.build.outputs.previous_version }}

permissions:
checks: write
contents: write

jobs:

build:
name: Build
runs-on: ubuntu-latest

outputs:
current_version: ${{ steps.current_version.outputs.value }}
previous_version: ${{ steps.previous_version.outputs.value }}

steps:

- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Set up Node.js
id: setup
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
id: dependencies
run: npm ci --force

- id: build
name: Build
run: npm run build

- name: Get current version
id: current_version
run: echo "value=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Get previous version
id: previous_version
run: |
git fetch --tags origin
echo "value=$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1 | cut -b 2-7)" >> $GITHUB_OUTPUT
38 changes: 38 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'CD'

on:
push:
branches:
- main

permissions:
checks: write
contents: write

jobs:

lint:
name: Lint
uses: ./.github/workflows/lint.yml

build:
name: Build
uses: ./.github/workflows/build.yml

publish_github:
name: Publish to GitHub
uses: ./.github/workflows/publish-github.yml
needs: [lint, build]
if: ${{ needs.build.outputs.current_version != needs.build.outputs.previous_version }}
secrets: inherit
with:
version: ${{ needs.build.outputs.current_version }}

publish_docker:
name: Publish to Docker Hub
uses: ./.github/workflows/publish-docker.yml
needs: [lint, build]
if: ${{ needs.build.outputs.current_version != needs.build.outputs.previous_version }}
secrets: inherit
with:
version: ${{ needs.build.outputs.current_version }}
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'CI'

on:
pull_request:

permissions:
checks: write
contents: write

jobs:

lint:
name: Lint
uses: ./.github/workflows/lint.yml
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Lint'

on:
workflow_call:

permissions:
checks: write
contents: write

jobs:

lint:
name: Lint
runs-on: ubuntu-latest

steps:

- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Set up Node.js
id: setup
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
id: dependencies
run: npm ci --force

- name: Lint
id: lint
run: npm run lint
62 changes: 62 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Publish to Docker Hub'

on:
workflow_call:
inputs:
version:
type: string
description: 'The version to publish'
required: true
secrets:
DOCKER_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
workflow_dispatch:
inputs:
version:
type: string
description: 'The version to publish'
required: true

permissions:
checks: write
contents: write

jobs:

publish_docker:
name: Publish to Docker Hub
runs-on: ubuntu-latest

steps:

- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Log in to Docker Hub
id: login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ github.repository }}
tags: |
type=raw,value=${{ inputs.version }},priority=1000
type=raw,value=latest
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
40 changes: 40 additions & 0 deletions .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Publish GitHub Tag and Release'

on:
workflow_call:
inputs:
version:
type: string
description: 'The version to publish'
required: true

permissions:
checks: write
contents: write

jobs:

publish_tag:
name: Publish GitHub Tag and Release
runs-on: ubuntu-latest

steps:

- name: Checkout
id: checkout
uses: actions/checkout@v3

- name: Create Tag
id: tag
uses: mathieudutour/github-tag-action@v6.1
with:
custom_tag: ${{ inputs.version }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create release
id: release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
name: ${{ steps.tag.outputs.new_tag }}
tag: ${{ steps.tag.outputs.new_tag }}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# next
.next
.vercel

# build
dist

# node
node_modules
npm-debug.log*

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

# docker
.env
docker-compose.override.yml

# restreamer
config/*
!config/.gitkeep
Loading

0 comments on commit a00b2b8

Please sign in to comment.