Jekyll Deploy #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
jekyll-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: echo concurrency group | |
run: echo ${{ github.workflow }}-${{ github.ref_name }} | |
- name: echo deploy branch | |
run: echo ${{ github.ref_name }} | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.2' | |
bundler-cache: true | |
- name: Jekyll Build ${{ github.ref_name }} | |
run: | | |
echo ${{ github.event.inputs.manual_deploy_branch }} | |
echo GITHUB_REF_NAME ${{ github.ref_name }} | |
LATEST_VERSION=$(jq -r '.current' _data/versions.json) | |
echo LATEST_VERSION $LATEST_VERSION | |
if [ "${{ github.ref_name }}" = "$LATEST_VERSION" ]; then | |
DESTINATION_KEY="latest" | |
elif [ "${{ github.ref_name }}" = ${{ github.event.repository.default_branch }} ]; then | |
#DESTINATION_KEY="staging" | |
DESTINATION_KEY="latest" | |
else | |
DESTINATION_KEY="${{ github.ref_name }}" | |
fi | |
echo "DESTINATION_KEY_ENV=$DESTINATION_KEY" >> $GITHUB_ENV | |
echo ${{ env.DESTINATION_KEY_ENV }} | |
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_ENV }} |