Last active
May 6, 2020 21:22
-
-
Save dvino/c6045830dac33415df898c04fd14c235 to your computer and use it in GitHub Desktop.
Automated build the Jekyll website from repository with a source and public it to othre repository wich use Github Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Jekyll site CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/checkout@v2 | |
with: | |
repository: ${{ secrets.GH_PAGES_REPO }} | |
token: ${{ secrets.JEKYLL_PAT }} | |
path: _site | |
fetch-depth: 0 | |
- uses: actions/cache@v1 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Build the website in the jekyll/builder container | |
run: | | |
U_ID="$(id -u):$(id -g)" | |
docker run \ | |
-v ${{ github.workspace }}:/srv/jekyll \ | |
-v ${{ github.workspace }}/_site:/srv/jekyll/_site \ | |
-v ${{ github.workspace }}/vendor/bundle:/usr/local/bundle \ | |
jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll && jekyll build --future --trace && chown -R $U_ID /srv/jekyll/_site" | |
- name: Push builded site to Github Pages | |
run: | | |
cd _site | |
git config --global user.name "${{ github.ACTOR }}" | |
git config --global user.email "${{ github.ACTOR }}@users.noreply.github.com" | |
if [[ $(git status -s) ]]; then | |
git add . | |
git commit -am "Automated build wesite" | |
git push origin master | |
else | |
echo nothing changes | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment