2019-03-26 09:50:54 +01:00
|
|
|
version: 2
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
docker:
|
2019-03-26 09:57:39 +01:00
|
|
|
- image: alpine:3.9.2
|
2019-03-26 09:50:54 +01:00
|
|
|
|
|
|
|
|
steps:
|
2019-03-26 09:57:39 +01:00
|
|
|
- run:
|
|
|
|
|
name: Install hugo
|
|
|
|
|
command: apk add hugo
|
|
|
|
|
|
2019-03-26 09:50:54 +01:00
|
|
|
- run:
|
|
|
|
|
name: Create site
|
|
|
|
|
command: hugo new site my-site
|
|
|
|
|
|
|
|
|
|
- run:
|
|
|
|
|
name: Clone the theme from the PR
|
|
|
|
|
working_directory: my-site
|
2019-03-26 09:57:39 +01:00
|
|
|
command: |
|
|
|
|
|
apk add git
|
|
|
|
|
git clone https://github.com/StefMa/hugo-fresh themes/hugo-fresh
|
2019-03-26 09:50:54 +01:00
|
|
|
- run:
|
|
|
|
|
working_directory: my-site/themes/hugo-fresh
|
|
|
|
|
command: |
|
2019-03-26 09:57:39 +01:00
|
|
|
if [[ ${CIRCLE_BRANCH} == "*pull*" ]]; then
|
|
|
|
|
git fetch origin ${CIRCLE_BRANCH}/head:BRANCHNAME
|
|
|
|
|
git checkout BRANCHNAME
|
|
|
|
|
else
|
|
|
|
|
git checkout ${CIRCLE_BRANCH}
|
|
|
|
|
fi
|
2019-03-26 09:50:54 +01:00
|
|
|
|
|
|
|
|
- run:
|
|
|
|
|
name: Replace default config
|
|
|
|
|
working_directory: my-site
|
|
|
|
|
command: |
|
|
|
|
|
rm config.toml
|
2019-03-26 09:57:39 +01:00
|
|
|
apk add curl
|
2019-03-26 09:50:54 +01:00
|
|
|
curl -O https://raw.githubusercontent.com/StefMa/hugo-fresh/master/exampleSite/config.yaml
|
2019-03-26 09:57:39 +01:00
|
|
|
- run:
|
|
|
|
|
name: Replace baseUrl in config
|
|
|
|
|
working_directory: my-site
|
|
|
|
|
command: |
|
|
|
|
|
apk add sed
|
|
|
|
|
URL=hugo-fresh-$(echo $CIRCLE_BRANCH | tr _ -)
|
|
|
|
|
if [ $CIRCLE_BRANCH == "master" ]; then
|
|
|
|
|
URL=hugo-fresh
|
|
|
|
|
fi
|
|
|
|
|
sed -i "s,http://something-fresh.org,https://${URL}.now.sh,g" config.yaml
|
|
|
|
|
cat config.yaml
|
2019-03-26 09:50:54 +01:00
|
|
|
|
|
|
|
|
- run:
|
|
|
|
|
name: Create hugo site
|
|
|
|
|
working_directory: my-site
|
|
|
|
|
command: hugo
|
2019-03-26 09:57:39 +01:00
|
|
|
|
2019-03-26 09:50:54 +01:00
|
|
|
- run:
|
2019-03-26 09:57:39 +01:00
|
|
|
name: Create now.json
|
|
|
|
|
working_directory: my-site/public
|
2019-03-26 09:50:54 +01:00
|
|
|
command: |
|
2019-03-26 09:57:39 +01:00
|
|
|
URL=hugo-fresh-$(echo $CIRCLE_BRANCH | tr _ -)
|
|
|
|
|
if [ $CIRCLE_BRANCH == "master" ]; then
|
|
|
|
|
URL=hugo-fresh
|
|
|
|
|
fi
|
|
|
|
|
echo "{ \"version\": 2, \"name\": \"hugo-fresh\", \"alias\": \"${URL}\", \"builds\": [{ \"src\": \"**\", \"use\": \"@now/static\" }] }" >> now.json
|
|
|
|
|
|
|
|
|
|
- run:
|
|
|
|
|
name: Install now CLI
|
|
|
|
|
command: |
|
|
|
|
|
apk add wget
|
|
|
|
|
wget -q https://github.com/zeit/now-cli/releases/download/14.2.3/now-alpine.gz
|
|
|
|
|
apk add gzip
|
|
|
|
|
gunzip now-alpine.gz
|
|
|
|
|
chmod a+x now-alpine
|
|
|
|
|
mv now-alpine /usr/local/bin/now
|
|
|
|
|
apk add libstdc++ libgcc
|
|
|
|
|
- run:
|
|
|
|
|
name: Publish to now.sh
|
|
|
|
|
working_directory: my-site/public
|
|
|
|
|
command: now --target production --token ${NOW_TOKEN}
|