-
Notifications
You must be signed in to change notification settings - Fork 4
67 lines (61 loc) · 2.38 KB
/
doc-publish.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
# Copyright (c) 2021-2024 TiaC Systems
# Copyright (c) 2021 Li-Pro.Net
# SPDX-License-Identifier: Apache-2.0
name: Documentation Publish
on:
workflow_run:
workflows: ["Documentation Build", "Documentation Remove"]
types: [completed]
jobs:
doc-publish:
name: Publish archived documentation actions from artifacts
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
uses: actions/github-script@v7
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "doc"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/doc.zip', Buffer.from(download.data));
- name: Upload documentation
env:
HOST: ${{ secrets.TSN_BRIDLE_DOCROOT_HOST }}
PORT: ${{ secrets.TSN_BRIDLE_DOCROOT_PORT }}
USER: ${{ secrets.TSN_BRIDLE_DOCROOT_USER }}
KEY: ${{ secrets.TSN_BRIDLE_DOCROOT_KEY }}
INBOX: ${{ secrets.TSN_BRIDLE_DOCROOT_INBOX }}
run: |
unzip doc.zip
mkdir -p ~/.ssh && \
ssh-keyscan -p ${PORT} ${HOST} >> ~/.ssh/known_hosts
touch ~/.ssh/private && \
chmod 600 ~/.ssh/private && \
echo -e "${KEY}" > ~/.ssh/private
# Don't upload the archive and workflow metadata
files=$(ls -I doc.zip -I pr.txt)
for file in ${files}; do
scp -i ~/.ssh/private "${file}" "scp://${USER}@${HOST}:${PORT}/${INBOX}/${file}"
done
- name: Add preview URL comment for PRs
uses: carlescufi/action-doc-url@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
urlroot: ${{ secrets.TSN_BRIDLE_GHPR_URL_ROOT }}
pr-prefix: "PR-"
pr-file: pr.txt
continue-on-error: true