-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (108 loc) · 4.56 KB
/
toPages.yml
File metadata and controls
128 lines (108 loc) · 4.56 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
name: Deploy to Pages
on:
workflow_dispatch:
inputs:
release_name:
description: 'Release name'
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up environment
run: |
sudo apt-get update
sudo apt-get install -y unzip curl jq
- name: Download package.zip from HelpViewer/HelpViewer
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_name="${{ github.event.inputs.release_name }}"
api_url="https://api.github.com/repos/HelpViewer/HelpViewer/releases"
asset_url=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$api_url" \
| jq -r '.[] | select(.name == "'"$release_name"'") | .assets[] | select(.name == "package.zip") | .url')
if [ -z "$asset_url" ]; then
echo "Asset package.zip not found for release $release_name"
exit 1
fi
curl -L -H "Accept: application/octet-stream" \
-H "Authorization: token $GITHUB_TOKEN" \
"$asset_url" -o package.zip
- name: Unzip package.zip
run: |
unzip -o package.zip
rm -f package.zip
touch .nojekyll
- name: Create hlp/ directories
run: |
mkdir -p hlp
mkdir -p hlp-user
mkdir -p hlp-aguide
mkdir -p hlp-dguide
- name: Download all zip assets from HelpViewer/helpHello
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_name="${{ github.event.inputs.release_name }}"
_reponame=helpHello
api_url="https://api.github.com/repos/HelpViewer/$_reponame/releases/tags/$release_name"
release=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$api_url")
hlpdir=hlp
echo "$release" | jq -c '.assets[] | select(.name | endswith(".zip"))' | while read asset; do
name=$(echo "$asset" | jq -r '.name')
url=$(echo "$asset" | jq -r '.url')
echo "Downloading $name..."
curl -L -H "Accept: application/octet-stream" \
-H "Authorization: token $GITHUB_TOKEN" \
"$url" -o "$hlpdir/$name"
done
_reponame=helpUser
api_url="https://api.github.com/repos/HelpViewer/$_reponame/releases/latest"
release=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$api_url")
hlpdir=hlp-user
echo "$release" | jq -c '.assets[] | select(.name | endswith(".zip"))' | while read asset; do
name=$(echo "$asset" | jq -r '.name')
url=$(echo "$asset" | jq -r '.url')
echo "Downloading $name..."
curl -L -H "Accept: application/octet-stream" \
-H "Authorization: token $GITHUB_TOKEN" \
"$url" -o "$hlpdir/$name"
done
_reponame=helpAuthorsGuide
api_url="https://api.github.com/repos/HelpViewer/$_reponame/releases/latest"
release=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$api_url")
hlpdir=hlp-aguide
echo "$release" | jq -c '.assets[] | select(.name | endswith(".zip"))' | while read asset; do
name=$(echo "$asset" | jq -r '.name')
url=$(echo "$asset" | jq -r '.url')
echo "Downloading $name..."
curl -L -H "Accept: application/octet-stream" \
-H "Authorization: token $GITHUB_TOKEN" \
"$url" -o "$hlpdir/$name"
done
_reponame=helpDevelop
api_url="https://api.github.com/repos/HelpViewer/$_reponame/releases/latest"
release=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "$api_url")
hlpdir=hlp-dguide
echo "$release" | jq -c '.assets[] | select(.name | endswith(".zip"))' | while read asset; do
name=$(echo "$asset" | jq -r '.name')
url=$(echo "$asset" | jq -r '.url')
echo "Downloading $name..."
curl -L -H "Accept: application/octet-stream" \
-H "Authorization: token $GITHUB_TOKEN" \
"$url" -o "$hlpdir/$name"
done
echo "" >> robots.txt
echo "Sitemap: https://helpviewer.github.io/s/sitemap.xml" >> robots.txt
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Release ${{ github.event.inputs.release_name }}" || echo "Nothing to commit"
git push