Skip to content

Commit 978420a

Browse files
committed
Add initials files & invalidate cache feature
1 parent 656876b commit 978420a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+63517
-1
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
lib/
3+
node_modules/
4+
jest.config.js

.eslintrc.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"ignorePatterns": ["dist"],
3+
"overrides": [
4+
{
5+
"files": ["src/**/*.{ts,tsx}"],
6+
"env": {
7+
"node": true
8+
},
9+
"parserOptions": {
10+
"tsconfigRootDir": ".",
11+
"project": "./tsconfig.json",
12+
"ecmaVersion": 2018,
13+
"sourceType": "module"
14+
},
15+
"parser": "@typescript-eslint/parser",
16+
"plugins": ["@typescript-eslint"],
17+
"extends": [
18+
"plugin:@typescript-eslint/recommended",
19+
"plugin:prettier/recommended"
20+
],
21+
"rules": {
22+
"no-console": "warn",
23+
"@typescript-eslint/no-floating-promises": "error",
24+
"@typescript-eslint/no-unused-vars": [
25+
"warn",
26+
{
27+
"args": "after-used",
28+
"argsIgnorePattern": "^_"
29+
}
30+
]
31+
}
32+
}
33+
]
34+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** -diff linguist-generated=true

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
8+
- package-ecosystem: npm
9+
directory: /
10+
schedule:
11+
interval: daily

.github/release-drafter.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name-template: 'v$NEXT_PATCH_VERSION'
2+
tag-template: 'v$NEXT_PATCH_VERSION'
3+
template: |
4+
$CHANGES

.github/workflows/codeql-analysis.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '42 5 * * 5'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
57+
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
60+
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
64+
65+
#- run: |
66+
# make bootstrap
67+
# make release
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

.github/workflows/deploy.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: 'Deploy'
2+
3+
concurrency:
4+
group: prod_deploy
5+
cancel-in-progress: false
6+
7+
on:
8+
repository_dispatch:
9+
workflow_dispatch:
10+
pull_request:
11+
types: [opened, synchronize, reopened, closed]
12+
push:
13+
branches:
14+
- master
15+
16+
jobs:
17+
deploy:
18+
name: 'Deploy'
19+
runs-on: ubuntu-20.04
20+
if: github.actor != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Configure AWS Credentials
25+
uses: aws-actions/configure-aws-credentials@v1
26+
with:
27+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
aws-region: us-east-1
30+
31+
- uses: badsyntax/github-action-aws-cloudformation@30e8484d108a13d803aa449c1ec1bd6aa4c932ff
32+
name: Update CloudFormation Stack
33+
id: update-stack
34+
with:
35+
githubToken: ${{ secrets.GITHUB_TOKEN }}
36+
stackName: 'static-example-richardwillis-cloudformation-stack'
37+
template: './cloudformation/cloudformation-s3bucket-example.yml'
38+
applyChangeSet: ${{ github.event_name != 'repository_dispatch' }}
39+
awsRegion: 'us-east-1'
40+
parameters: |
41+
S3BucketName=static-example-richardwillis-info-us-east-1&
42+
S3AllowedOrigins=https://static-example.richardwillis.info,https://*.preview.static-example.richardwillis.info&
43+
CloudFrontRootHosts=static-example.richardwillis.info&
44+
CertificateARN=arn:aws:acm:us-east-1:008215002370:certificate/39df7626-7d2f-42e9-94f4-a3ce61ca3d5e
45+
46+
- uses: badsyntax/github-action-aws-s3@9537cd6d2013140b1d4e11ff526c5d75084c01df
47+
name: Sync mutable HTML files to S3
48+
id: sync-html-s3
49+
with:
50+
bucket: ${{ steps.update-stack.outputs.S3BucketName }}
51+
action: 'sync'
52+
srcDir: './out'
53+
filesGlob: '**/*.html'
54+
awsRegion: 'us-east-1'
55+
prefix: 'root'
56+
stripExtensionGlob: '**/**.html'
57+
cacheControl: 'public,max-age=0,s-maxage=31536000,must-revalidate'
58+
59+
- uses: badsyntax/github-action-aws-s3@9537cd6d2013140b1d4e11ff526c5d75084c01df
60+
name: Sync immutable files to S3
61+
id: sync-immutable-s3
62+
with:
63+
bucket: ${{ steps.update-stack.outputs.S3BucketName }}
64+
action: 'sync'
65+
srcDir: './out'
66+
filesGlob: 'css/**'
67+
awsRegion: 'us-east-1'
68+
prefix: 'root'
69+
cacheControl: 'public,max-age=31536000,immutable'
70+
71+
- uses: ./
72+
name: Invalidate CloudFront Cache
73+
id: invalidate-cloudfront-cache
74+
with:
75+
distributionId: ${{ steps.update-stack.outputs.CFDistributionId }}
76+
awsRegion: 'us-east-1'
77+
originPrefix: 'root'
78+
invalidatePaths: ${{ steps.sync-html-s3.outputs.S3SyncedFiles }}
79+
defaultRootObject: 'index.html'
80+
81+
# - name: Output Synced Files
82+
# run: |
83+
# echo "Synced HTML Files: $S3SyncedHTMLFiles"
84+
# echo "Synced Immutable Files: $S3SyncedImmutableFiles"
85+
# env:
86+
# # Use outputs from the S3 step
87+
# S3SyncedHTMLFiles: ${{ steps.sync-html-s3.outputs.S3SyncedFiles }}
88+
# S3SyncedImmutableFiles: ${{ steps.sync-immutable-s3.outputs.S3SyncedFiles }}

.github/workflows/release-drafter.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release Drafter
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
types: [opened, reopened, synchronize]
8+
permissions:
9+
contents: write
10+
pull-requests: read
11+
12+
jobs:
13+
update_release_draft:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Draft release
17+
uses: release-drafter/release-drafter@v5
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'Build & Test'
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- 'releases/*'
9+
10+
jobs:
11+
check-dist:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set Node.js 16.x
16+
uses: actions/[email protected]
17+
with:
18+
node-version: 16.x
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Rebuild the dist/ directory
22+
run: |
23+
npm run build
24+
npm run package
25+
- name: Compare the expected and actual dist/ directories
26+
run: |
27+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
28+
echo "Detected uncommitted changes after build. See status below:"
29+
git diff
30+
exit 1
31+
fi
32+
test:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Set Node.js 16.x
37+
uses: actions/[email protected]
38+
with:
39+
node-version: 16.x
40+
- name: Install dependencies
41+
run: npm ci
42+
- name: Run all
43+
run: |
44+
npm run lint
45+
npm run format-check
46+
npm test
47+
npm run build
48+
npm run package

.gitignore

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/
92+
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/
100+
101+
# direnv
102+
.envrc

0 commit comments

Comments
 (0)