Skip to content

Commit

Permalink
allow deployment to Github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyom-e committed Sep 13, 2023
1 parent 55045cf commit 2523aa6
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 8 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/push-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
branches:
- production

name: 🚀 Deploy production
concurrency: push_production

env:
CI: true

jobs:
build-format-lint-test:
name: 🚀 Build, lint and test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: "⚙️📦️ Install & cache node dependencies"
uses: ./.github/actions/install-node-deps
- name: "⚙️🛠️ Build"
run: yarn build
- name: "🧪🖼️ Test linter"
run: yarn test:lint
- name: "🧪🔬 Run unit tests"
run: yarn test:unit

deploy:
name: 🚀 Deploy production
needs: build-format-lint-test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- name: "⚙️📦️ Install & cache node dependencies"
uses: ./.github/actions/install-node-deps
- name: "⚙️📜 Setup git config"
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
- name: 🚀 Deploy production
run: yarn deploy
28 changes: 28 additions & 0 deletions .scripts/rebase_production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# FOR PROJECT MAINTAINERS ONLY
# Update branches
git fetch origin || exit 1
git checkout solutions || exit 1
git pull || exit 1

# Check number of commits
tags=("step2", "step3", "step4", "helpers", "step5", "step6", "step7", "step8", "step9", "step10", "step11", "_solutions_")
number_of_commits=$(git log --oneline solutions ^origin/start-branch | wc -l)
if [ "$commit_diff" -ne ${#tags[@]} ]; then
echo "The number of commits between start-branch and solutions is not correct, please update the branches or the script"
exit 2
fi

git checkout production || exit 1
# Rebase on solutions on start-branch
git rebase solutions || exit 1

# Check tests pass
CI=true yarn test || exit 3

echo ""
echo "================================================================="
echo "Rebase of production branch done, please push changes: "
echo "git push --force-with-lease "
echo "You may allow force push on the repo settings "
echo "================================================================="
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ yarn test:unit
```sh
yarn lint
```

### Deploy to GitHub pages

```sh
yarn deploy
```
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/dojo-battleship/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Dojo Battleship Theodo</title>
</head>
<body>
<div id="app"></div>
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"name": "dojo-battleship",
"version": "0.0.0",
"private": true,
"homepage": "https://theodo.github.io/dojo-battleship/",
"scripts": {
"dev": "vite",
"build": "vite build",
"deploy": "yarn build && gh-pages -d dist",
"preview": "vite preview --port 4173",
"test:lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path .gitignore",
"test:unit": "vitest --environment jsdom",
Expand All @@ -21,10 +23,12 @@
"@vue/test-utils": "^2.4.1",
"eslint": "^8.48.0",
"eslint-plugin-vue": "^9.17.0",
"gh-pages": "^6.0.0",
"jsdom": "^22.1.0",
"prettier": "^3.0.3",
"sass": "^1.66.1",
"vite": "^4.4.9",
"vite-plugin-singlefile": "^0.13.5",
"vitest": "^0.34.4"
}
}
9 changes: 5 additions & 4 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { viteSingleFile } from "vite-plugin-singlefile";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
plugins: [vue(), viteSingleFile()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
"@": fileURLToPath(new URL("./src", import.meta.url))
}
}
});
Loading

0 comments on commit 2523aa6

Please sign in to comment.