Skip to content

Commit 880d3de

Browse files
kouadamreeve
andauthored
## What's Changed Add support for publishing to https://arrow.apache.org/dotnet/ : * The `main` branch -> https://arrow.apache.org/dotnet/main/ * The `vX.Y.Z` tag -> https://arrow.apache.org/dotnet/X.Y.Z/ * The latest `vX.Y.Z` tag -> https://arrow.apache.org/dotnet/current/ * https://arrow.apache.org/dotnet/ -> https://arrow.apache.org/dotnet/current/ Add support for previewing on fork: https://${GITHUB_ID}.github.io/arrow-dotnet/ Example: https://kou.github.io/arrow-dotnet/ See docs/README.md how to prepare fork to preview. Add support for commenting preview URL on PR. Closes #26. --------- Co-authored-by: Adam Reeve <[email protected]>
1 parent 734dc72 commit 880d3de

File tree

7 files changed

+260
-11
lines changed

7 files changed

+260
-11
lines changed

.github/workflows/pr_comment.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: PR comment
19+
20+
on:
21+
pull_request_target:
22+
types:
23+
- opened
24+
25+
permissions:
26+
contents: read
27+
issues: write
28+
pull-requests: write
29+
30+
jobs:
31+
preview-url:
32+
name: Preview URL
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Comment
36+
env:
37+
GH_TOKEN: ${{ github.token }}
38+
PR_REPOSITORY: ${{ github.event.pull_request.base.repo.full_name }}
39+
FORK_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
40+
PR_NUMBER: ${{ github.event.number }}
41+
run: |
42+
configure_url="https://github.com/apache/arrow-dotnet/blob/main/docs/README.md#preview-on-forks"
43+
fork_owner=${FORK_REPOSITORY%/*}
44+
fork_repository=${FORK_REPOSITORY#*/}
45+
{
46+
echo "Documentation preview URL: https://${fork_owner}.github.io/${fork_repository}"
47+
echo ""
48+
echo "If the preview URL doesn't work, you may need to configure your fork repository for preview."
49+
echo "See ${configure_url} for instructions on how to configure."
50+
} | tee body.md
51+
gh pr comment ${PR_NUMBER} \
52+
--body-file body.md \
53+
--repo ${PR_REPOSITORY}

.github/workflows/rc.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,80 @@ jobs:
170170
mv release-*/* ./
171171
dev/release/verify_rc.sh "${VERSION}" "${RC}"
172172
173+
docs:
174+
name: Documentation
175+
needs:
176+
- target
177+
runs-on: ubuntu-latest
178+
timeout-minutes: 5
179+
env:
180+
RC: ${{ needs.target.outputs.rc }}
181+
VERSION: ${{ needs.target.outputs.version }}
182+
steps:
183+
- name: Checkout
184+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
185+
- name: Build documentation
186+
shell: bash
187+
run: ci/scripts/docs.sh $(pwd)
188+
- name: Package
189+
run: |
190+
id="apache-arrow-dotnet-docs-${VERSION}"
191+
tar_gz="${id}.tar.gz"
192+
mv docs/_site "${id}"
193+
tar czf "${tar_gz}" "${id}"
194+
sha256sum "${tar_gz}" > "${tar_gz}.sha256"
195+
sha512sum "${tar_gz}" > "${tar_gz}.sha512"
196+
- name: Upload
197+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
198+
with:
199+
name: release-docs
200+
path: |
201+
apache-arrow-dotnet-docs-*.tar.gz*
202+
- name: Upload pages
203+
if: |
204+
github.event_name == 'push' &&
205+
github.repository != 'apache/arrow-dotnet'
206+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
207+
with:
208+
path: apache-arrow-dotnet-docs-${{ env.VERSION }}
209+
- name: Deploy for production
210+
if: |
211+
github.event_name == 'push' &&
212+
github.repository == 'apache/arrow-dotnet' &&
213+
github.ref_name == 'main'
214+
run: |
215+
ci/scripts/update_site.sh "${VERSION}"
216+
cd site
217+
git config user.name "github-actions[bot]"
218+
git config user.email "github-actions[bot]@users.noreply.github.com"
219+
if [ "$(git diff --cached)" != "" ]; then
220+
git commit -m "Update docs for ${GITHUB_SHA}"
221+
git push origin "$(git branch --show-current)"
222+
fi
223+
224+
docs-deploy-fork:
225+
name: Deploy on fork
226+
if: >-
227+
github.event_name == 'push' &&
228+
github.repository != 'apache/arrow-dotnet'
229+
needs:
230+
- docs
231+
permissions:
232+
pages: write
233+
id-token: write
234+
environment:
235+
name: github-pages
236+
url: ${{ steps.deployment.outputs.page_url }}
237+
runs-on: ubuntu-latest
238+
steps:
239+
- name: Deploy to GitHub Pages
240+
id: deployment
241+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
242+
173243
upload:
174244
name: Upload
175245
needs:
246+
- docs
176247
- target
177248
- verify
178249
runs-on: ubuntu-latest

.github/workflows/release.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,31 @@ jobs:
5757
--title "Apache Arrow .NET ${version}" \
5858
--verify-tag \
5959
dists/*
60+
- name: Checkout asf-site
61+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
62+
with:
63+
ref: asf-site
64+
path: site
65+
- name: Update documentation
66+
run: |
67+
version=${GITHUB_REF_NAME#v}
68+
tar_gz=${PWD}/dists/apache-arrow-dotnet-docs-${version}.tar.gz
69+
70+
pushd site
71+
72+
rm -rf current
73+
mkdir -p current
74+
pushd current
75+
tar xf "${tar_gz}" --strip-components=1
76+
popd
77+
git add current
78+
79+
rm -rf "${version}"
80+
cp -a current "${version}"
81+
git add "${version}"
82+
83+
git config user.name "github-actions[bot]"
84+
git config user.email "github-actions[bot]@users.noreply.github.com"
85+
86+
git commit -m "Update docs for ${version}"
87+
git push origin "$(git branch --show-current)"

.github/workflows/test.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,3 @@ jobs:
8383
- name: Test
8484
shell: bash
8585
run: ci/scripts/test.sh $(pwd)
86-
87-
docs:
88-
name: Build Documentation
89-
runs-on: ubuntu-latest
90-
timeout-minutes: 5
91-
steps:
92-
- name: Checkout
93-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
94-
- name: Build documentation
95-
shell: bash
96-
run: ci/scripts/docs.sh $(pwd)

ci/scripts/update_site.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
set -exu
21+
22+
version="${1}"
23+
24+
html_escape() {
25+
# & -> &amp; must be the first substitution
26+
sed -e "s/&/&amp;/g" \
27+
-e "s/</&lt;/g" \
28+
-e "s/>/&gt;/g" \
29+
-e "s/\"/&quot;/g" \
30+
-e "s/'/&apos;/g"
31+
}
32+
33+
if ! git fetch origin asf-site; then
34+
git worktree add --orphan -b asf-site site
35+
else
36+
git worktree add site -B asf-site origin/asf-site
37+
fi
38+
39+
tar_gz="${PWD}/apache-arrow-dotnet-docs-${version}.tar.gz"
40+
41+
extract_docs() {
42+
local destination="${1}"
43+
44+
rm -rf "${destination}"
45+
mkdir -p "${destination}"
46+
pushd "${destination}"
47+
tar xf "${tar_gz}" --strip-components=1
48+
popd
49+
git add "${destination}"
50+
}
51+
52+
pushd site
53+
# Synchronize .asf.yaml
54+
cp -a ../.asf.yaml ./
55+
git add .asf.yaml
56+
57+
# Update https://arrow.apache.org/dotnet/main/
58+
extract_docs main
59+
60+
# Create .htaccess
61+
cat >.htaccess <<HTACCESS
62+
RedirectMatch "^/dotnet/$" "/dotnet/current/"
63+
HTACCESS
64+
git add .htaccess
65+
popd

docs/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an
12+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
KIND, either express or implied. See the License for the
14+
specific language governing permissions and limitations
15+
under the License.
16+
-->
17+
18+
# Docs
19+
20+
## Preview on fork
21+
22+
When implementing changes to the website on a fork, the GitHub Actions
23+
workflow behaves differently.
24+
25+
On a commit to all branches, the rendered static site will be
26+
published to GitHub Pages using GitHub Actions. The latest commit is
27+
only visible because all publications use the same output location:
28+
https://${YOUR_GITHUB_ACCOUNT}.github.io/arrow-dotnet/
29+
30+
You need to configure your fork repository to use this feature:
31+
32+
1. Enable GitHub Pages on your fork:
33+
1. Open https://github.com/${YOUR_GITHUB_ACCOUNT}/arrow-dotnet/settings/pages
34+
2. Select "GitHub Actions" as "Source"
35+
2. Accept publishing GitHub Pages from all branches on your fork:
36+
1. Open https://github.com/${YOUR_GITHUB_ACCOUNT}/arrow-dotnet/settings/environments
37+
2. Select the "github-pages" environment
38+
3. Change the default "Deployment branches and tags" rule:
39+
1. Press the "Edit" button
40+
2. Change the "Name pattern" to `*` from `main` or `gh-pages`
41+
42+
See also the [GitHub Pages documentation](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow).

docs/docfx.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"**/*.{md,yml}"
2424
],
2525
"exclude": [
26+
"README.md",
2627
"_site/**",
2728
"images/**"
2829
]

0 commit comments

Comments
 (0)