Skip to content

Commit

Permalink
Fix #3 deploy website
Browse files Browse the repository at this point in the history
  • Loading branch information
boly38 committed Oct 9, 2024
1 parent f22bbe9 commit a75410a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 12 deletions.
17 changes: 5 additions & 12 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,9 @@ $ npm run serve

### Deployment

Using SSH:
When some changes has been locally tested, then accepted, and (via pull-request) then merged on `main` branch :
- you could run GitHub Actions `patch.yml` [workflow](./workflows/patch.yml).
- as result a new version patch is produced on `prod` branch.
- then the `deploy.yml` [workflow](./workflows/deploy.yml) will be triggered on `prod` push to build and deploy the website on GitHub-pages : https://boly38.github.io/chickenbot-web/.

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
You can start workflow and follow them under [actions tab](https://github.com/boly38/chickenbot-web/actions).
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy_GHPages

on:
push:
branches:
- prod

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [ 22.x ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: |
echo "install"
npm ci
echo "show outdated (if any)"
npm outdated --depth=3 || echo "you must think about update your dependencies :)"
- name: Build Docusaurus site
run: npm run build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GH_ACTIONS_TOKEN }}
publish_dir: ./build
33 changes: 33 additions & 0 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Patch
on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [ 22.x ]

steps:
- name: Git checkout
uses: actions/checkout@v3
with:
ref: 'prod'
token: ${{ secrets.GH_ACTIONS_TOKEN }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Patch
run: |
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global user.name 'github-actions[bot]'
git fetch --all
git checkout main
npm version patch
git branch -f prod
git push origin main prod --tags

0 comments on commit a75410a

Please sign in to comment.