summaryrefslogtreecommitdiff
path: root/.github/workflows/ghpages.yml
blob: 5b72b9b7c0cf47625903889b000aa6db3393b10c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Publish to gh-pages

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Create Docker image
      run: docker build . -t asciidoc

    - name: Get short SHA
      id: slug
      run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"

    - name: Build gh-pages
      run: docker run --rm -v $(pwd):/srv/asciidoc asciidoc /bin/bash -c "cd /srv/asciidoc; bash build_website.sh"

    - name: Fix permissions
      run: sudo chown -R $(id -u):$(id -g) gh-pages

    - name: Commit files
      run: |
        cd gh-pages
        git config --local user.email "matt.peveler@gmail.com"
        git config --local user.name "MasterOdin"
        git add . || :
        git commit -s -m "deploy: ${{ steps.slug.outputs.sha8 }}" -a || :

    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        directory: gh-pages
        branch: gh-pages