diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ad381f5 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,65 @@ +name: "Deployment" +on: + push: + branches: ["main"] + workflow_dispatch: +jobs: + codeql-analysis: + name: CodeQL Analysis + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: ["javascript", "typescript"] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" + deploy-to-gh-pages: + needs: [codeql-analysis] + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install dependencies + run: npm i --legacy-peer-deps + - name: Configure git + run: | + git config --global user.name '${{ secrets.COMMIT_USER }}' + git config --global user.email '${{ secrets.COMMIT_USER }}@users.noreply.github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --import + git config --global user.signingkey ${{ secrets.GPG_KEY_ID }} + git config --global commit.gpgsign true + - name: Deploy to gh-pages + run: | + npm run build-for-gh-pages + git clone https://github.com/${{ github.repository_owner }}/${{ github.repository_owner }}.github.io.git + rm -rf ./${{ github.repository_owner }}.github.io/* + cp -r dist/* ./${{ github.repository_owner }}.github.io/ + cp docs/PAGES_README.md ./${{ github.repository_owner }}.github.io/README.md + cp docs/PAGES_CNAME ./${{ github.repository_owner }}.github.io/CNAME + cd ./${{ github.repository_owner }}.github.io/ + git remote remove origin + git remote add origin https://${{ secrets.PRIVATE_TOKEN }}@github.com/${{ github.repository_owner }}/${{ github.repository_owner }}.github.io + git add . + git diff-index --quiet HEAD || git commit -m "Deploy to GitHub Pages" + git push --set-upstream origin main diff --git a/.gitignore b/.gitignore index a547bf3..8d11970 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ dist-ssr *.njsproj *.sln *.sw? + +# Environment Variables +.env.development \ No newline at end of file diff --git a/docs/PAGES_CNAME b/docs/PAGES_CNAME new file mode 100644 index 0000000..a3cd988 --- /dev/null +++ b/docs/PAGES_CNAME @@ -0,0 +1 @@ +ark-tech.in \ No newline at end of file diff --git a/docs/PAGES_README.md b/docs/PAGES_README.md new file mode 100644 index 0000000..b149775 --- /dev/null +++ b/docs/PAGES_README.md @@ -0,0 +1,2 @@ +# ArkTech's Main Website +> Source Code: [Click Here](https://github.com/ArkTechOrg/ArkTech-Main-Frontend) \ No newline at end of file diff --git a/package.json b/package.json index 955d5a2..6ae6849 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", - "preview": "vite preview" + "preview": "vite preview", + "build-for-gh-pages": "vite build && cp dist/index.html dist/404.html" }, "dependencies": { "clsx": "^2.1.1",