Open-Hardware-Leaders / ohlwebsite

Repository hosting website source files for the Open Hardware Leaders program
https://openhardware4.me
GNU General Public License v3.0
5 stars 3 forks source link

Deploying automatically to our production website #5

Open jurra opened 4 years ago

jurra commented 4 years ago

Continuous integration and deployment works fine in the ohlwebsite. Andre and I found an issue with regard to the domain name itself. I can recall the details but I think is in an older issue.

The current solution

Commit changes and automatically push to the current production website.

Setup this following these steps:

  1. Go to .git\hooks folder in your local ohlwebsite repository. Make sure to unhide these folder if is hidden.
  2. Go to post-commit file and replace its current code with the following code:
    
    #!/bin/sh

abort on errors

set -e

load .env

eval "$(cat .env <(echo) <(declare -x))"

build

npm run build

navigate into the build output directory

cd dist

if you are deploying to a custom domain

echo 'www.example.com' > CNAME

git init

echo "openhardware4.me" > CNAME

git add -A git commit -m 'deploy'

git push -f https://github.com/Open-Hardware-Leaders/open-hardware-leaders.github.io.git master

cd -

git push origin


3. (Recommended but not compulsory for now) Test your change also locally running `npm start`.
4. Make your commits normally and the production repo will be updated automatically.
vektorious commented 4 years ago

In my .git/hooks folder is just README.sample. I guess I have to create a new file then?

jurra commented 4 years ago

yes new file called post-commit.sh