forked from opensearch-project/documentation-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Piotr Chmielnik
committed
Feb 22, 2024
1 parent
ed7db4d
commit 5e5f716
Showing
4 changed files
with
89 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Publish Website eoed-docs.eliatra.com | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 1.3.x-ee | ||
pull_request: | ||
|
||
env: | ||
WEBSITE_URL: 'eoed-docs.eliatra.com' | ||
WEBSITE_VERSION: '1.x' | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
ruby-version: '3.0' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' | ||
bundler-cache: true | ||
|
||
build: | ||
needs: setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ needs.setup.outputs.ruby-version }} | ||
bundler-cache: true | ||
- name: Update _config.yml | ||
run: | | ||
sed -i '/^url:/c\url: "https://${{ env.WEBSITE_URL }}"' _config.yml | ||
sed -i '/^baseurl:/c\baseurl: "/docs/${{ env.WEBSITE_VERSION }}"' _config.yml | ||
cat _config.yml|grep -e "^url:" -e "^baseurl:" | ||
- run: bundle exec jekyll build --future | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: site-artifacts | ||
path: _site | ||
retention-days: 1 | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: site-artifacts | ||
path: _site | ||
|
||
|
||
- name: Install SSH key | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SFTP_SSH_PRIVATE_KEY }} | ||
|
||
- name: Upload Folder | ||
run: | | ||
sudo apt install lftp -y | ||
lftp --version | ||
echo "Start SFTP upload" | ||
lftp -u ${{ secrets.SFTP_USERNAME }}, -e "set sftp:connect-program 'ssh -a -x -o StrictHostKeyChecking=no'; mkdir -p /var/www/${{ env.WEBSITE_URL }}/html/${{ env.WEBSITE_VERSION }}; mirror --reverse --parallel=20 --verbose _site/ /var/www/${{ env.WEBSITE_URL }}/html/${{ env.WEBSITE_VERSION }}/; quit" sftp://${{ secrets.SFTP_SERVER }} | ||
post_deploy: | ||
needs: deploy | ||
runs-on: ubuntu-latest | ||
if: github.event_name != 'pull_request' | ||
steps: | ||
- name: Purge Cloudflare Cache | ||
run: | | ||
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ | ||
-X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.ELIATRA_CLOUDFLARE_ZONEID }}/purge_cache" \ | ||
-H "Authorization: Bearer ${{ secrets.ELIATRA_CLOUDFLARE_DECACHE_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
--data '{"purge_everything":true}') | ||
if [ "$STATUS_CODE" -ne 200 ]; then | ||
echo "Cloudflare API call failed with status $STATUS_CODE" | ||
exit 1 | ||
else | ||
echo "Cloudflare cache purged successfully" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
User-agent: * | ||
Disallow: / |