Skip to content

Commit

Permalink
added deploy in github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
IASV committed Sep 11, 2023
1 parent ec1e9ba commit 85a1c06
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/gh-pages-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Deploy to Github Pages
on:
push:
branches:
- main
jobs:
gh-pages-deploy:
name: Deploying to Github Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
- name: Install packages
run: npm i
- name: Set Creds
run: git config user.name "IASV" && git config user.email "ivanantoniosuarezvillalba@gmail.com"
- name: Deploy
run: npm run deploy
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"format": "prettier --write src/"
"format": "prettier --write src/",
"deploy": "node scripts/gh-pages-deploy.js"
},
"dependencies": {
"@tabler/icons-vue": "^2.34.0",
"execa": "^8.0.1",
"pinia": "^2.1.6",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
Expand Down
26 changes: 26 additions & 0 deletions scripts/gh-pages-deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable no-console */
const execa = require("execa");
const fs = require("fs");
(async () => {
try {
await execa("git", ["checkout", "--orphan", "gh-pages"]);
// eslint-disable-next-line no-console
console.log("Building started...");
await execa("npm", ["run", "build"]);
// await execa("yarn", ["build"]);
// Understand if it's dist or build folder
const folderName = fs.existsSync("dist") ? "dist" : "build";
await execa("git", ["--work-tree", folderName, "add", "--all"]);
await execa("git", ["--work-tree", folderName, "commit", "-m", "gh-pages"]);
console.log("Pushing to gh-pages...");
await execa("git", ["push", "origin", "HEAD:gh-pages", "--force"]);
await execa("rm", ["-r", folderName]);
await execa("git", ["checkout", "-f", "main"]);
await execa("git", ["branch", "-D", "gh-pages"]);
console.log("Successfully deployed, check your settings");
} catch (e) {
// eslint-disable-next-line no-console
console.log(e.message);
process.exit(1);
}
})();
3 changes: 3 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/my-portfolio' : '/',
};

0 comments on commit 85a1c06

Please sign in to comment.