This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (108 loc) · 4.46 KB
/
gh-pages-build.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: gh-pages-build
on:
workflow_dispatch:
push:
env:
# renovate: datasource=github-tags depName=gohugoio/hugo
HUGO_VERSION: 0.128.0
permissions:
contents: write
jobs:
gh-pages-build:
runs-on: ubuntu-latest
permissions:
contents: write
deployments: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
submodules: true
- name: Setup Hugo
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 18
- name: Prepare public directory
run: |
set -euxo pipefail
mkdir public
cp LICENSE README.md public/
- name: Set BASE_DOMAIN
id: base_domain
run: |
if [[ "${GITHUB_REF_NAME}" = "main" ]]; then
BASE_DOMAIN="${{ github.event.repository.name }}"
else
BASE_DOMAIN="$( echo ${{ github.event.repository.name }} | tr . - ).pages.dev"
fi
echo "BASE_DOMAIN=${BASE_DOMAIN}" | tee -a "${GITHUB_OUTPUT}"
- name: Copy posts to blog directories
run: |
set -euxo pipefail
mkdir -p {hugo-blowfish,hugo-loveit}/content jekyll-chirpy/_posts
cp -r my-test-posts/* hugo-blowfish/content/
cp -r my-test-posts/* hugo-loveit/content/
cp -r my-test-posts/* jekyll-chirpy/_posts/
cp -r my-test-posts/posts/* docosaurus-test/blog/
- name: Setup Ruby
uses: ruby/setup-ruby@1d0e911f615a112e322369596f10ee0b95b010ae # v1.183.0
with:
ruby-version: 3.1
bundler-cache: true
working-directory: jekyll-chirpy
- name: Build site
run: |
set -euxo pipefail
cd jekyll-chirpy
bundle exec jekyll build --destination ../public/jekyll-chirpy --baseurl /jekyll-chirpy/
env:
JEKYLL_ENV: "production"
- name: Build Docosaurus
run: |
set -euxo pipefail
sed -i 's/${{ github.event.repository.name }}/${{ steps.base_domain.outputs.BASE_DOMAIN }}/' docosaurus-test/docusaurus.config.js
npm --prefix docosaurus-test install
npm --prefix docosaurus-test run build -- --out-dir ../public/docosaurus-test
- name: Build hugo pages
run: |
set -euxo pipefail
# Change links inside config.toml
sed -i "s/${{ github.event.repository.name }}/${{ steps.base_domain.outputs.BASE_DOMAIN }}/" config.toml
hugo --gc --destination public
cd hugo-blowfish
# Not working ...
# hugo --gc --baseURL "https://${{ steps.base_domain.outputs.BASE_DOMAIN }}/hugo-blowfish" --destination ../public/hugo-blowfish
cd ../hugo-loveit
hugo --gc --baseURL "https://${{ steps.base_domain.outputs.BASE_DOMAIN }}/hugo-loveit" --destination ../public/hugo-loveit
# - name: Check broken links
# uses: ruzickap/action-my-broken-link-checker@v2
# with:
# url: https://${{ steps.base_domain.outputs.BASE_DOMAIN }}
# pages_path: ./public
# cmd_params: '--exclude=(linkedin.com) --buffer-size=8192 --max-connections-per-host=5 --color=always --rate-limit=5 --header="User-Agent:curl/7.54.0" --skip-tls-verification'
- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: true
cname: ${{ github.event.repository.name }}
- name: Web Page
run: |
cat << EOF | tee -a "${GITHUB_STEP_SUMMARY}"
* :low_brightness: <https://${{ steps.base_domain.outputs.BASE_DOMAIN }}>
EOF
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # v1.5.0
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/gh-pages' }}
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
branch: main
directory: ./public
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: blog-test-ruzicka-dev