github.com/google/cloudprober@v0.11.3/.github/workflows/hugo.yml (about)

     1  name: Build and deploy gh-pages
     2  
     3  on:
     4    push:
     5      paths:
     6      - 'docs/**'
     7      - '.github/workflows/hugo.yml'
     8  
     9  jobs:
    10    build-and-deploy:
    11  
    12      runs-on: ubuntu-latest
    13  
    14      steps:
    15      - uses: actions/checkout@v1
    16  
    17      - name: Set up hugo
    18        uses: peaceiris/actions-hugo@v2
    19        with:
    20          hugo-version: '0.61.0'
    21  
    22      - name: Setup public worktree
    23        run: cd docs && git worktree add public gh-pages
    24  
    25      - name: Create a branch for pull request
    26        env:
    27          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    28        run: |
    29          cd docs/public
    30          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
    31          git push origin --delete gh-pages-github-action || true
    32          git checkout -b gh-pages-github-action gh-pages
    33  
    34      - name: Build pages
    35        run: cd docs && hugo
    36  
    37      - name: Deploy
    38        env:
    39          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    40        run: |
    41          cd docs/public
    42          git config user.name "${GITHUB_ACTOR}"
    43          git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
    44          git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
    45          git add --all
    46          git status
    47          git diff-index --quiet HEAD || git commit -m "Update gh-pages" && git push --set-upstream origin gh-pages-github-action
    48  
    49