diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 37fc46f9..00000000 --- a/.gitattributes +++ /dev/null @@ -1,48 +0,0 @@ -# See this article for reference: https://help.github.com/articles/dealing-with-line-endings/ -# Refreshing repo after line ending change: -# https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings - -# Handle line endings automatically for files detected as text -# and leave all files detected as binary untouched. -* text=auto - -# -# The above will handle all files NOT found below -# -# These files are text and should be normalized (Convert crlf => lf) -# Use lf as eol for these files -.editorconfig text eol=lf -.gitignore text eol=lf -*.css text eol=lf -*.df text eol=lf -*.htm text eol=lf -*.html text eol=lf -*.java text eol=lf -*.js text eol=lf -*.json text eol=lf -*.jsp text eol=lf -*.jspf text eol=lf -*.md text eol=lf -*.properties text eol=lf -*.scss text eol=lf -*.sh text eol=lf -*.tld text eol=lf -*.ts text eol=lf -*.txt text eol=lf -*.xml text eol=lf - -# These files are binary and should be left untouched -# (binary is a macro for -text -diff) -*.class binary -*.dll binary -*.ear binary -*.gif binary -*.ico binary -*.jar binary -*.jpg binary -*.jpeg binary -*.png binary -*.so binary -*.war binary - -docs/** linguist-documentation=false diff --git a/.github/workflows/codesee.yml b/.github/workflows/codesee.yml deleted file mode 100644 index 1ad9abb7..00000000 --- a/.github/workflows/codesee.yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches: - - main - pull_request_target: - types: [opened, synchronize, reopened] - -name: CodeSee - -permissions: read-all - -jobs: - codesee: - runs-on: ubuntu-latest - continue-on-error: true - name: Analyse the repo with CodeSee - steps: - - uses: Codesee-io/codesee-action@v2 - with: - codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1e50ecce..616f2d01 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,31 +1,79 @@ -name: Deploy to Auth-Server +name: Deploy on: push: branches: - main + workflow_dispatch: + inputs: + environment: + type: choice + description: 'Deploy Environment' + options: + - dev + - prod + invalidate: + description: 'Invalidate CloudFront Cache' + type: boolean + default: true + jobs: deploy: name: Deploy runs-on: ubuntu-latest + env: + DIST_NAME: ${{ vars.DIST_NAME }} + S3_BUCKET: ${{ vars.S3_BUCKET }} + DEPLOY_DIR: 'public' + steps: - - name: Configure AWS - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-2 - - - name: Create Deployment - id: deploy - env: - APP_NAME: auth-server - DEPLOY_GROUP: gitlang - run: | - aws deploy create-deployment --ignore-application-stop-failures \ - --application-name ${{ env.APP_NAME }} \ - --deployment-group-name ${{ env.DEPLOY_GROUP }} \ - --deployment-config-name CodeDeployDefault.AllAtOnce \ - --file-exists-behavior OVERWRITE \ - --github-location repository=${{ github.repository }},commitId=${{ github.sha }} + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build + run: | + set -x + npm i + sed -i "1i console.log('Updated:', '$(TZ=PST8PDT date)')" client/src/index.ts + npm run build:prod + + - name: Configure AWS + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Sync to S3 + id: sync + run: | + aws s3 sync ${DEPLOY_DIR} s3://${S3_BUCKET} --delete + + - name: Invalidate CloudFront + id: invalidate + if: ${{ inputs.invalidate == true }} + run: | + dist_id="$(aws cloudfront list-distributions \ + --query "DistributionList.Items[?Comment=='${DIST_NAME}'].Id" \ + --output text)" + + if [ -z "$dist_id" ]; then + echo "No distribution found with comment: ${DIST_NAME}" + exit 1 + fi + + echo "Invalidating ${dist_id} for ${DIST_NAME}" + invalidation_id="$(aws cloudfront create-invalidation \ + --distribution-id "$dist_id" \ + --paths "/*" \ + --query "Invalidation.Id" \ + --output text)" + + echo "Invalidation started: ${invalidation_id}" + + aws cloudfront wait invalidation-completed \ + --distribution-id "$dist_id" \ + --id "$invalidation_id" + + echo "Invalidation completed" diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index 956f2da5..00000000 --- a/docs/404.html +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - GitLang - - - - - - - - - - - - - - - - - - -
-
- -
-
- - - diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 92882ce1..00000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -gitlang.net \ No newline at end of file diff --git a/init.sh b/init.sh deleted file mode 100644 index 65871a3f..00000000 --- a/init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -if [ -f "/home/ec2-user/server/init.sh" ]; then - chmod +x /home/ec2-user/server/init.sh - /home/ec2-user/server/init.sh -# else run auth-server deploy workflow -fi diff --git a/package.json b/package.json index cd5a5d94..af3636e7 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "description": "View language usage per repo or total by username", "main": "client/src/index.ts", "scripts": { - "dev": "NODE_ENV=development webpack --mode development -w", + "build:dev": "NODE_ENV=development webpack --mode development -w", + "build:prod": "NODE_ENV=production webpack --mode production", "fix": "eslint --fix '**/*'", - "prod": "NODE_ENV=production webpack --mode production", "start:client": "ts-node local/client.ts", "start:server": "ts-node local/server.ts" }, diff --git a/docs/public/assets/favicon.ico b/public/assets/favicon.ico similarity index 100% rename from docs/public/assets/favicon.ico rename to public/assets/favicon.ico diff --git a/docs/public/assets/img/gitlang.svg b/public/assets/img/gitlang.svg similarity index 100% rename from docs/public/assets/img/gitlang.svg rename to public/assets/img/gitlang.svg diff --git a/docs/public/assets/social.png b/public/assets/social.png similarity index 100% rename from docs/public/assets/social.png rename to public/assets/social.png diff --git a/docs/index.html b/public/index.html similarity index 99% rename from docs/index.html rename to public/index.html index 447854ca..14e10d63 100644 --- a/docs/index.html +++ b/public/index.html @@ -1,4 +1,4 @@ - + diff --git a/stop.sh b/stop.sh deleted file mode 100644 index 422c5662..00000000 --- a/stop.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -if [ -f "/home/ec2-user/server/stop.sh" ]; then - chmod +x /home/ec2-user/server/stop.sh - /home/ec2-user/server/stop.sh -# else run auth-server deploy workflow -fi diff --git a/webpack.config.ts b/webpack.config.ts index 57c386e3..13c092d7 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -11,7 +11,7 @@ const mode = process.env.NODE_ENV as const production = mode === 'production'; const SRC_DIR = path.join(path.resolve(), '/client/src'); -const DIST_DIR = path.join(path.resolve(), '/docs/public/dist'); +const DIST_DIR = path.join(path.resolve(), '/public/dist'); const configuration: Configuration = { entry: `${SRC_DIR}/index.ts`,