forked from stretchr/testify
-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (127 loc) · 4.35 KB
/
Copy pathupdate-doc.yml
File metadata and controls
138 lines (127 loc) · 4.35 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
name: "Update documentation"
permissions:
contents: read
on:
push:
tags:
- v*
branches: [ "master" ]
paths:
- docs/**
- hack/doc-site/**
- .github/workflows/update-doc.yml
pull_request:
paths:
- docs/**
- hack/doc-site/**
- .github/workflows/update-doc.yml
concurrency:
group: "pages"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
build-doc:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: '1'
submodules: recursive
sparse-checkout: |
hack/
docs/
-
name: Get all tags [go-openapi repo]
if: ${{ github.repository == 'go-openapi/testify' }}
run: |
git fetch origin --prune --update-shallow --tags 'refs/tags/*:refs/tags/*'
-
name: Get all tags [fork]
if: ${{ github.repository != 'go-openapi/testify' }}
run: |
git remote add upstream "https://github.com/go-openapi/testify"
git fetch upstream --prune --update-shallow --tags 'refs/tags/*:refs/tags/*'
git fetch origin --prune --update-shallow --tags 'refs/tags/*:refs/tags/*'
-
name: Initialize theme
env:
RELEARN_VERSION: 9.0.3
run: |
cd hack/doc-site/hugo
# Clone theme
curl -sL -o relearn.tgz https://github.com/McShelby/hugo-theme-relearn/archive/refs/tags/"${RELEARN_VERSION}".tar.gz
tar xf relearn.tgz
rm -rf themes/hugo-relearn
mv "hugo-theme-relearn-${RELEARN_VERSION}" hugo-relearn
mv hugo-relearn themes/
-
name: Prepare config
run: |
# Builds a commit-dependant extra config to inject parameterization.
# HUGO doesn't support config from the command line.
#
# Set specific parameters that are used in some parameterized document.
# This is used to keep up-to-date installation instructions.
cd hack/doc-site/hugo
ROOT=$(git rev-parse --show-toplevel)
VERSION_MESSAGE="Documentation set for latest master."
REQUIRED_GO_VERSION=$(grep "^go\s" "${ROOT}"/go.mod|cut -d" " -f2)
LATEST_RELEASE=$(git tag --list --sort -version:refname 'v*' 2>/dev/null | head -1 || echo "dev")
BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo " Latest release: ${LATEST_RELEASE}"
echo " Go version: ${REQUIRED_GO_VERSION}"
echo " Build time: ${BUILD_TIME}"
echo " Version message: ${VERSION_MESSAGE}"
# Generate dynamic config
cat testify.yaml.template \
| sed "s|{{ GO_VERSION }}|${REQUIRED_GO_VERSION}|g" \
| sed "s|{{ LATEST_RELEASE }}|${LATEST_RELEASE}|g" \
| sed "s|{{ VERSION_MESSAGE }}|${VERSION_MESSAGE}|g" \
| sed "s|{{ BUILD_TIME }}|${BUILD_TIME}|g" \
> testify.yaml
-
name: Build site with Hugo
uses: crazy-max/ghaction-hugo@58bd8ea36dbac3f6155d275a04e0b55604a93c48 # v3.2.0
with:
version: v0.153.3 # <- pin the HUGO version, as they often break things
extended: true
args: >
--config hugo.yaml,testify.yaml
--buildDrafts
--cleanDestinationDir
--minify
--printPathWarnings
--ignoreCache
--noBuildLock
--logLevel info
--source ${{ github.workspace }}/hack/doc-site/hugo"
-
name: Upload artifact
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
with:
path: hack/doc-site/hugo/public
deploy-doc:
if: ${{ github.event_name != 'pull_request' }}
needs: build-doc
outputs:
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
-
name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
-
name: Report URL
run: |
echo "::notice::Deployed doc site to ${{ steps.deployment.outputs.page_url }}"