forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (134 loc) · 6.2 KB
/
preview.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Surge.sh Preview
on:
workflow_run:
workflows: ["Quarkus Documentation CI"]
types:
- completed
defaults:
run:
shell: bash
jobs:
preview:
runs-on: ubuntu-latest
permissions:
actions: read
issues: write
# this is unfortunately needed to be able to write comments on pull requests
pull-requests: write
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
with:
repository: quarkusio/quarkusio.github.io
fetch-depth: 5000
fetch-tags: false
- uses: actions/checkout@v4
with:
repository: quarkusio/quarkus
path: quarkus-main
- name: Install git-restore-time
run: sudo apt-get install -y git-restore-mtime
- name: Restore mtime
run: git restore-mtime
- name: Download PR Artifact
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: documentation
path: documentation-temp
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Store PR id as variable
id: pr
run: |
pr=$(<documentation-temp/pr-id.txt)
if ! [[ $pr =~ ^[0-9]+$ ]] ; then
echo "PR id extracted from documentation-temp/pr-id.txt is not a number: $pr"
exit 1
fi
echo "id=$(<documentation-temp/pr-id.txt)" >> $GITHUB_OUTPUT
- name: Sync documentation
shell: bash
# make sure we override the script coming from the artifact with the version from the main repository
run: |
rm ./documentation-temp/docs/sync-web-site.sh
cp -a ./quarkus-main/docs/sync-web-site.sh ./documentation-temp/docs/
chmod 755 ./documentation-temp/docs/sync-web-site.sh
./documentation-temp/docs/sync-web-site.sh main ../../
rm -rf documentation-temp
rm -rf quarkus-main
- name: Set up ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3
- name: Build Jekyll site
uses: limjh16/jekyll-action-ts@v2
with:
enable_cache: true
### Enables caching. Similar to https://github.com/actions/cache.
#
format_output: false
### Uses prettier https://prettier.io to format jekyll output HTML.
#
# prettier_opts: '{ "useTabs": true }'
### Sets prettier options (in JSON) to format output HTML. For example, output tabs over spaces.
### Possible options are outlined in https://prettier.io/docs/en/options.html
#
prettier_ignore: '*'
### Ignore paths for prettier to not format those html files.
### Useful if the file is exceptionally large, so formatting it takes a while.
### Also useful if HTML compression is enabled for that file / formatting messes it up.
#
# jekyll_src: sample_site
### If the jekyll website source is not in root, specify the directory. (in this case, sample_site)
### By default, this is not required as the action searches for a _config.yml automatically.
#
#gem_src: quarkusio
### By default, this is not required as the action searches for a _config.yml automatically.
### However, if there are multiple Gemfiles, the action may not be able to determine which to use.
### In that case, specify the directory. (in this case, sample_site)
###
### If jekyll_src is set, the action would automatically choose the Gemfile in jekyll_src.
### In that case this input may not be needed as well.
#
# key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
# restore-keys: ${{ runner.os }}-gems-
### In cases where you want to specify the cache key, enable the above 2 inputs
### Follows the format here https://github.com/actions/cache
#
custom_opts: '--config _config.yml,_only_latest_guides_config.yml'
### If you need to specify any Jekyll build options, enable the above input
### Flags accepted can be found here https://jekyllrb.com/docs/configuration/options/#build-command-options
- name: Reduce the size of the website to be compatible with surge
run: |
find assets/images/posts/ -mindepth 1 -maxdepth 1 -type d -mtime +100 -exec rm -rf _site/{} \;
find newsletter/ -mindepth 1 -maxdepth 1 -type d -mtime +100 -exec rm -rf _site/{} \;
rm -rf _site/assets/images/worldtour/2023
rm -rf _site/assets/images/desktopwallpapers
- name: Publishing to surge for preview
id: deploy
run: npx surge@0.23.1 ./_site --domain https://quarkus-pr-main-${PR_ID}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
env:
PR_ID: ${{ steps.pr.outputs.id }}
- name: Update PR status comment on success
uses: quarkusio/action-helpers@main
with:
action: maintain-one-comment
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ steps.pr.outputs.id }}
body: |
🎊 PR Preview ${{ github.sha }} has been successfully built and deployed to https://quarkus-pr-main-${{ steps.pr.outputs.id }}-preview.surge.sh/version/main/guides/
- Images of blog posts older than 3 months are not available.
- Newsletters older than 3 months are not available.
<img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
body-marker: <!-- Preview status comment marker -->
- name: Update PR status comment on failure
uses: quarkusio/action-helpers@main
if: ${{ failure() }}
with:
action: maintain-one-comment
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ steps.pr.outputs.id }}
body: |
😭 Deploy PR Preview failed.
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
body-marker: <!-- Preview status comment marker -->