-
Notifications
You must be signed in to change notification settings - Fork 9
73 lines (63 loc) · 2.42 KB
/
publish.yml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Website
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: "publish"
cancel-in-progress: true
env:
WEBSITE_SOURCES_DIR: sources
WEBSITE_CONTENT_REPO: eclipse-glsp/glsp-website
WEBSITE_CONTENT_DIR: hugo-public-dist
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ env.WEBSITE_SOURCES_DIR }}
- name: Checkout content website
uses: actions/checkout@v3
with:
repository: ${{ env.WEBSITE_CONTENT_REPO }}
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ env.WEBSITE_CONTENT_DIR }}
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.78.1'
extended: true
- name: Prune current content
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: git rm -rf *
- name: Build website
working-directory: ${{ env.WEBSITE_SOURCES_DIR }}
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: hugo --minify -d ${{ github.workspace }}/${{ env.WEBSITE_CONTENT_DIR }}
- name: Check for content changes
id: git-check
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: |
git add -A
echo ::set-output name=modified::$(if git diff --cached --exit-code --quiet; then echo "false"; else echo "true"; fi)
- name: Push content changes
if: steps.git-check.outputs.modified == 'true'
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: |
git config user.name ${{ github.event.head_commit.author.name }}
git config user.email ${{ github.event.head_commit.author.email }}
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all
git remote set-url origin https://x-access-token:${{ secrets.GH_ACTION_TOKEN }}@github.com/${{ env.WEBSITE_CONTENT_REPO }}
git commit -am "${{ github.event.head_commit.message }}"
git push origin