forked from opensearch-project/documentation-website
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.64 KB
/
jekyll-deploy.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
name: Jekyll Deploy
on:
workflow_dispatch:
inputs:
manual_deploy_branch:
description: "Which branch do you want to manually deploy"
type: string
required: true
workflow_call:
permissions:
contents: write
# Temporary
env:
SITE_URL: https://docsstaging.opensearch.net
VERSIONS_JSON: https://raw.githubusercontent.com/peterzhuamazon/documentation-website/refs/heads/main/_data/versions.json
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.manual_deploy_branch || github.ref_name }}
cancel-in-progress: true
jobs:
jekyll-deploy:
runs-on: ubuntu-latest
steps:
- name: Set variables
run: |
deploy_branch=${{ github.event.inputs.manual_deploy_branch || github.ref_name }}
echo "DEPLOY_BRANCH=$deploy_branch" >> $GITHUB_ENV
echo DEPLOY_BRANCH $deploy_branch
echo concurrent group ${{ github.workflow }}-$deploy_branch
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Jekyll Build ${{ env.DEPLOY_BRANCH }}
run: |
curl -SLO $VERSIONS_JSON
LATEST_VERSION=$(jq -r '.current' ./versions.json)
echo LATEST_VERSION $LATEST_VERSION
if [ "$DEPLOY_BRANCH" = "$LATEST_VERSION" ]; then
destination_key="latest"
elif [ "$DEPLOY_BRANCH" = ${{ github.event.repository.default_branch }} ]; then
destination_key="staging"
else
destination_key="$DEPLOY_BRANCH"
fi
echo "DESTINATION_KEY=$destination_key" >> $GITHUB_ENV
echo DESTINATION_KEY $destination_key
bundle install
CURRENT_VERSION=$(jq -r '.current' _data/versions.json)
sed -i -e "s|^url:.*$|url:\ \"$SITE_URL\"|g" _config.yml
sed -i -e "s|baseurl:.*$|baseurl:\ \"/docs/$destination_key\"|g" _config.yml
curl -s -f -o _data/alert.yml https://raw.githubusercontent.com/opensearch-project/project-website/prod/_data/alert.yml || rm -rf _data/alert.yml
bundle exec jekyll build --trace
ls -l _site
cat _config.yml | grep "baseurl:"
cat _config.yml | grep "url:"
- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: _site
clean: true
target-folder: docs/${{ env.DESTINATION_KEY }}
- name: Deploy GitHub Pages (Latest)
if: env.DESTINATION_KEY == 'latest'
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: _site
clean: true
target-folder: docs/${{ env.DEPLOY_BRANCH }}