forked from openchamber/openchamber
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (76 loc) · 2.96 KB
/
Copy pathdocs-source.yml
File metadata and controls
86 lines (76 loc) · 2.96 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
name: Docs Source
on:
push:
branches: [main]
paths:
- "packages/docs/**"
- "scripts/docs/**"
- "package.json"
release:
types: [published]
workflow_dispatch:
inputs:
release_tag:
description: "Optional existing tag to upload docs source archive"
required: false
type: string
permissions:
contents: write
jobs:
validate-and-package:
runs-on: ubuntu-latest
outputs:
archive_name: ${{ steps.archive.outputs.archive_name }}
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
- name: Validate docs source
run: bun run docs:validate
- name: Build docs source archive
id: archive
run: |
mkdir -p artifacts
ARCHIVE_NAME="openchamber-docs-source-${GITHUB_SHA::8}.tar.gz"
tar -czf "artifacts/${ARCHIVE_NAME}" -C packages/docs .
echo "archive_name=${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
- name: Upload workflow artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: docs-source
path: artifacts/${{ steps.archive.outputs.archive_name }}
retention-days: 14
- name: Upload archive to release tag
if: ${{ github.event_name == 'release' || github.event.inputs.release_tag != '' }}
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
tag_name: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }}
files: artifacts/${{ steps.archive.outputs.archive_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger openchamber-website docs sync (optional)
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'workflow_dispatch' }}
env:
WEBSITE_REPO: openchamber/openchamber-website
WEBSITE_TOKEN: ${{ secrets.OPENCHAMBER_WEBSITE_REPO_TOKEN }}
SOURCE_REF: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
run: |
if [ -z "$WEBSITE_TOKEN" ]; then
echo "OPENCHAMBER_WEBSITE_REPO_TOKEN not set; skip dispatch."
exit 0
fi
curl -sS -X POST \
-H "Authorization: Bearer $WEBSITE_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/$WEBSITE_REPO/dispatches \
-d @- <<JSON
{
"event_type": "docs_source_updated",
"client_payload": {
"source_repo": "${{ github.repository }}",
"source_ref": "$SOURCE_REF",
"archive_name": "${{ steps.archive.outputs.archive_name }}"
}
}
JSON