Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 46 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,47 @@ on:
push:
branches: ["feature/angular"]

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

permissions:
contents: write

jobs:
npm:
uses: craigiswayne/ci-cd/.github/workflows/_npm-install-build-lint-test.yml@v0.0.6
with:
test_command: 'test:ci'
build_artifact_path: 'dist/prototype'
build_artifact_name: 'prototype-build-artifact'

# download_artifact:
# needs: [npm]
# runs-on: ubuntu-latest
# steps:
# - name: Download Build Artifact
# uses: actions/download-artifact@v4
# with:
# name: artifact
# # where to download to
# path: artifacts/my-test-artifact

# checkout:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# fetch-tags: true

publish_to_ghcr:
needs: [npm]
uses: craigiswayne/ci-cd/.github/workflows/docker-image-to-ghcr.yml@v0.0.6
permissions:
contents: read
packages: write

determine_version:
runs-on: ubuntu-latest

Expand All @@ -27,15 +64,22 @@ jobs:
echo "value=$LATEST_GIT_TAG" >> "$GITHUB_OUTPUT"

publish_to_docker_hub:
uses: craigiswayne/ci-cd/.github/workflows/docker-image-to-docker-hub.yml@feature/reusable-workflow
needs: [
npm
]
uses: craigiswayne/ci-cd/.github/workflows/docker-image-to-docker-hub.yml@v0.0.5
with:
docker_hub_username: 'craigiswayne'
docker_hub_repository: 'prototype'
secrets:
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

release:
needs: [determine_version, publish_to_docker_hub]
needs: [
npm,
determine_version,
publish_to_docker_hub
]
runs-on: ubuntu-latest

steps:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Pull Request Checks"

on:
pull_request:

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

jobs:
npm:
uses: craigiswayne/ci-cd/.github/workflows/_npm-install-build-lint-test.yml@v0.0.5
with:
test_command: 'test:ci'
run_lint: false
28 changes: 17 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
FROM node:alpine AS build
WORKDIR /usr/src/app
LABEL description="Like codepen...\
...but offline"
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build --prod
FROM nginx:stable-alpine-slim
LABEL maintainer="craigiswayne@gmail.com"
RUN apk update && apk add --no-cache openssl

RUN mkdir /etc/nginx/certs

RUN openssl req -x509 -nodes -days 365 \
-subj "/C=XX/ST=SomeState/L=SomeCity/O=MyOrg/CN=localhost" \
-newkey rsa:2048 -keyout /etc/nginx/certs/your_domain.key \
-out /etc/nginx/certs/your_domain.crt

ARG BUILD_DIR=./dist/prototype/browser
ENV BUILD_DIR=$BUILD_DIR

COPY ./dist/prototype/browser /usr/share/nginx/html
COPY docker.nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 443

FROM nginx:stable-alpine-slim
COPY --from=build /usr/src/app/dist/prototype/browser /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
24 changes: 24 additions & 0 deletions docker.nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {
listen 80;
server_name _;
return 301 https://localhost;
}

server {
listen 443 ssl default_server;
server_name _;

ssl_certificate /etc/nginx/certs/your_domain.crt;
ssl_certificate_key /etc/nginx/certs/your_domain.key;

# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_prefer_server_ciphers on;
# ssl_ciphers 'ECDHE+AESGCM:CHACHA20';

root /usr/share/nginx/html;
index index.html index.htm;

location / {
try_files $uri $uri/ /index.html;
}
}
106 changes: 62 additions & 44 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
// @ts-check
const eslint = require("@eslint/js");
const tseslint = require("typescript-eslint");
const angular = require("angular-eslint");

module.exports = tseslint.config(
{
files: ["**/*.ts"],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
rules: {
"comma-dangle": ["error", "never"],
"@angular-eslint/directive-selector": [
"error",
{
type: "attribute",
prefix: "app",
style: "camelCase",
},
],
"@angular-eslint/component-selector": [
"error",
{
type: "element",
prefix: "app",
style: "kebab-case",
},
],
},
},
{
files: ["**/*.html"],
extends: [
...angular.configs.templateRecommended,
...angular.configs.templateAccessibility,
],
rules: {},
}
);
// @ts-check

// Allows us to bring in the recommended core rules from eslint itself
const eslint = require('@eslint/js');

// Allows us to use the typed utility for our config, and to bring in the recommended rules for TypeScript projects from typescript-eslint
const tseslint = require('typescript-eslint');

// Allows us to bring in the recommended rules for Angular projects from angular-eslint
const angular = require('angular-eslint');

// Export our config array, which is composed together thanks to the typed utility function from typescript-eslint
module.exports = tseslint.config(
{
// Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc)
files: ['**/*.ts'],
extends: [
// Apply the recommended core rules
eslint.configs.recommended,
// Apply the recommended TypeScript rules
...tseslint.configs.recommended,
// Optionally apply stylistic rules from typescript-eslint that improve code consistency
...tseslint.configs.stylistic,
// Apply the recommended Angular rules
...angular.configs.tsRecommended,
],
// Set the custom processor which will allow us to have our inline Component templates extracted
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
processor: angular.processInlineTemplates,
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'app',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: 'app',
style: 'kebab-case',
},
],
},
},
{
// Everything in this config object targets our HTML files (external templates,
// and inline templates as long as we have the `processor` set on our TypeScript config above)
files: ['**/*.html'],
extends: [
// Apply the recommended Angular template rules
...angular.configs.templateRecommended,
// Apply the Angular template rules which focus on accessibility of our apps
...angular.configs.templateAccessibility,
],
rules: {},
},
);
Loading