Skip to content

Commit 14a7e4f

Browse files
committed
Updated CI for automated publications (#373)
1 parent 15af543 commit 14a7e4f

File tree

3 files changed

+28
-43
lines changed

3 files changed

+28
-43
lines changed

.github/workflows/docs.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ on:
77
- '.github/workflows/**'
88
workflow_dispatch:
99
inputs:
10-
version:
11-
description: 'Version of library that is being documented'
10+
build_id:
11+
description: 'Id of TeamCity build that produced the Dokka artifact.'
12+
required: true
13+
dry_run:
14+
type: boolean
15+
description: "Dry run. If set to true, the action will not actually publish the pages, but will assemble the artifact."
16+
default: true
1217
required: true
1318

1419
permissions:
1520
id-token: write
1621
pages: write
22+
contents: read
1723

1824
env:
1925
INSTANCE: 'kotlinx-rpc/rpc'
@@ -90,10 +96,23 @@ jobs:
9096
run: unzip -O UTF-8 -qq '${{ env.ARTIFACT }}' -d ${{ env.ASSEMBLE_DIR }}
9197

9298
- name: Download Dokka
93-
uses: actions/download-artifact@v4
94-
with:
95-
name: dokka-${{ inputs.version }}
96-
path: ${{ env.DOKKA_ARTIFACT }}
99+
run: |
100+
if [ -z "${{ inputs.build_id }}" ]; then
101+
echo "'build_id' is not set"
102+
exit 1
103+
fi
104+
105+
echo "Downloading Dokka artifact, build id: ${{ inputs.build_id }}"
106+
107+
artifact_url="https://krpc.teamcity.com/app/rest/builds/id:${{ inputs.build_id }}/artifacts/content/${{ env.DOKKA_ARTIFACT }}"
108+
echo "Downloading Dokka artifact from URL: $artifact_url"
109+
110+
curl -v -s -f -L -H "Authorization: Bearer ${{ secrets.TEAMCITY_TOKEN }}" "$artifact_url" -o "${{ env.DOKKA_ARTIFACT }}"
111+
112+
if [ -z "$(ls | grep -x ${{ env.DOKKA_ARTIFACT }})" ]; then
113+
echo "Failed to download Dokka artifact, asset id: ${{ inputs.build_id }}"
114+
exit 1
115+
fi
97116
98117
- name: Unzip Dokka
99118
run: unzip -O UTF-8 -qq '${{ env.DOKKA_ARTIFACT }}' -d ${{ env.ASSEMBLE_DIR }}/api
@@ -110,7 +129,7 @@ jobs:
110129
retention-days: 7
111130

112131
deploy:
113-
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
132+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && !inputs.dry_run
114133
environment:
115134
name: github-pages
116135
url: ${{ steps.deployment.outputs.page_url }}
@@ -138,7 +157,7 @@ jobs:
138157
uses: actions/deploy-pages@v4
139158

140159
publish-indexes:
141-
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
160+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && !inputs.dry_run
142161
needs: [ build, test, assemble, deploy ]
143162
runs-on: ubuntu-latest
144163
container:

.github/workflows/dokka.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

updateSitemap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ current_date=$(date +%Y-%m-%d)
3232
temp_file=$(mktemp)
3333

3434
# Extract the first line from sitemap file (XML header), removing closing urlset tag if present
35-
head -n 1 "$sitemap_file" | sed -En 's/<\/urlset>//' > "$temp_file"
35+
head -n 1 "$sitemap_file" | sed -En 's/<\/urlset>//p' > "$temp_file"
3636

3737
# Find all HTML files in the API docs directory recursively
3838
find "$api_docs_dir" -type f -name "*.html" | while read -r html_file; do

0 commit comments

Comments
 (0)