Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marvel-uiuc authored Sep 30, 2024
0 parents commit 5ce6734
Show file tree
Hide file tree
Showing 23 changed files with 684 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/delete_development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: delete_development
on:
workflow_dispatch:
env:
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2
- name: Delete S3 bucket
run: aws s3 rm s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME --recursive
- name: Invalidate Cloudfront cache
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME*"
93 changes: 93 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: deploy
on:
release:
types: [published]
env:
MAJORVERSION: ''
MINORVERSION: ''
FULLVERSION: ''
PRERELEASE: ''
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: 'Get Version'
id: get_version
uses: dhkatz/get-version-action@v3.0.0

- name: 'Check for correct naming convention'
if: ${{ !steps.get_version.outputs.is-semver }}
run: exit 1
- name: 'Get major version from tag'
run: echo "MAJORVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
- name: 'Get minor version from tag'
run: echo "MINORVERSION=${GITHUB_BRANCH}.${GITHUB_BRANCH_MINOR}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
GITHUB_BRANCH_MINOR: ${{ steps.get_version.outputs.minor }}
- name: Get patch (full) version from tag
run: echo "FULLVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.version-without-v }}
- name: Get prelease version from tag
run: echo "PRERELEASE=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.prerelease }}
- name: Display major version install
run: echo "Installing major version ${MAJORVERSION} for ${COMPONENT_NAME}"
- name: Display minor version install
run: echo "Installing minor version ${MINORVERSION} for ${COMPONENT_NAME}"
- name: Display patch (full) version install
run: echo "Installing patch (full) version ${FULLVERSION} for ${COMPONENT_NAME}"
- name: Production run
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: echo "Running production deployment"
- name: Prerelease run
if: ${{ steps.get_version.outputs.prerelease != '' }}
run: echo "Running development deployment"

- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2

- name: Deploy toolbox to S3 bucket for major version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MAJORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for major version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MAJORVERSION*"
- name: Deploy toolbox to S3 bucket for minor version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MINORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for minor version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MINORVERSION*"
- name: Deploy toolbox to S3 bucket for patch (full) version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for patch (full) version
if: ${{ steps.get_version.outputs.prerelease == '' }}
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$FULLVERSION*"
- name: Deploy toolbox to S3 bucket for full version dev
if: ${{ steps.get_version.outputs.prerelease != '' }}
run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for full version dev
if: ${{ steps.get_version.outputs.prerelease != '' }}
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$FULLVERSION*"
- name: Deploy toolbox to S3 bucket for latest dev
if: ${{ steps.get_version.outputs.prerelease != '' }}
run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/latest --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for latest dev
if: ${{ steps.get_version.outputs.prerelease != '' }}
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/latest*"
38 changes: 38 additions & 0 deletions .github/workflows/deploy_development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: deploy_development
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
default: ''
type: string
env:
MAJORVERSION: ''
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Get version from input
run: echo "VERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ github.event.inputs.version }}
- name: Display version install
run: echo "Installing dev version ${VERSION}"

- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2
- name: Deploy toolbox to S3 bucket
run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$VERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$VERSION*"
37 changes: 37 additions & 0 deletions .github/workflows/deploy_development_manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: deploy_development_manual
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
default: ''
type: string
env:
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Get version from input
run: echo "VERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ github.event.inputs.version }}
- name: Display version install
run: echo "Installing dev version ${VERSION} for component ${COMPONENT_NAME}"

- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2
- name: Deploy toolbox to S3 bucket
run: aws s3 sync ./dist/ s3://dev.toolkit.illinois.edu/content/$COMPONENT_NAME/$VERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT_DEV }} --paths "/$COMPONENT_NAME/$VERSION*"
64 changes: 64 additions & 0 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: deploy_production
on:
push:
tags: [ '**' ]
env:
MAJORVERSION: ''
MINORVERSION: ''
FULLVERSION: ''
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: 'Get Version'
id: get_version
uses: battila7/get-version-action@v2

- name: 'Check for correct naming convention'
if: ${{ !steps.get_version.outputs.is-semver }}
run: exit 1
- name: 'Get major version from tag'
run: echo "MAJORVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
- name: 'Get minor version from tag'
run: echo "MINORVERSION=${GITHUB_BRANCH}.${GITHUB_BRANCH_MINOR}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.major }}
GITHUB_BRANCH_MINOR: ${{ steps.get_version.outputs.minor }}
- name: Get patch (full) version from tag
run: echo "FULLVERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ steps.get_version.outputs.version-without-v }}
- name: Display major version install
run: echo "Installing major version ${MAJORVERSION}"
- name: Display minor version install
run: echo "Installing minor version ${MINORVERSION}"
- name: Display patch (full) version install
run: echo "Installing patch (full) version ${FULLVERSION}"

- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2

- name: Deploy toolbox to S3 bucket for major version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MAJORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for major version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MAJORVERSION*"
- name: Deploy toolbox to S3 bucket for minor version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$MINORVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for minor version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$MINORVERSION*"
- name: Deploy toolbox to S3 bucket for patch (full) version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$FULLVERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for patch (full) version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$FULLVERSION*"
38 changes: 38 additions & 0 deletions .github/workflows/deploy_production_manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: deploy_production_manual
on:
workflow_dispatch:
inputs:
version:
description: 'Version number'
required: true
default: ''
type: string
env:
COMPONENT_NAME: ${{ github.event.repository.name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Get version from input
run: echo "VERSION=${GITHUB_BRANCH}" >> $GITHUB_ENV
env:
GITHUB_BRANCH: ${{ github.event.inputs.version }}
- name: Display version install
run: echo "Installing production version ${VERSION} for component ${COMPONENT_NAME}"

- run: npm install
- run: npm rebuild
- run: npm run-script build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ vars.TOOLKIT_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TOOLKIT_AWS_ACCESS_SECRET }}
aws-region: us-east-2

- name: Deploy toolbox to S3 bucket for version
run: aws s3 sync ./dist/ s3://cdn.toolkit.illinois.edu/content/$COMPONENT_NAME/$VERSION --delete --acl bucket-owner-full-control
- name: Invalidate Cloudfront cache for version
run: aws cloudfront create-invalidation --distribution-id ${{ vars.TOOLKIT_AWS_CLOUDFRONT }} --paths "/$COMPONENT_NAME/$VERSION*"
21 changes: 21 additions & 0 deletions .github/workflows/publish_npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: publish_npm
on:
workflow_dispatch:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Install to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.TOOLKIT_NPM_SECRET}}
31 changes: 31 additions & 0 deletions .github/workflows/templating.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Apply caz templating

on: [push]

jobs:
run-caz:
# Avoid running more than once
if: ${{ github.repository != 'web-illinois/toolkit-template' && github.repository != 'marvel-uiuc/template-ilw' && github.run_number == 1 }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Apply caz template
run: npx -y caz ./ output --name ${{ github.event.repository.name }} --repository ${{ github.repository }}
- name: Commit template changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
rm -rf template index.js .gitignore package-lock.json README.md
cp -rT output .
rm -rf output
git add -A
git commit -a -m "chore: init template"
git push --force
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
/package-lock.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Web at Illinois

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 5ce6734

Please sign in to comment.