From 92434dbcb88d4c6aa361ea83edd786e6e80a5349 Mon Sep 17 00:00:00 2001 From: Piotr Chmielnik Date: Mon, 19 Feb 2024 15:22:57 +0100 Subject: [PATCH] Publish 1.3 to server --- .github/workflows/jekyll-build.yml | 16 ----- .github/workflows/link-checker.yml | 26 -------- .github/workflows/publish_site.yml | 97 ++++++++++++++++++++++++++++++ robots.txt | 2 + 4 files changed, 99 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/jekyll-build.yml delete mode 100644 .github/workflows/link-checker.yml create mode 100644 .github/workflows/publish_site.yml create mode 100644 robots.txt diff --git a/.github/workflows/jekyll-build.yml b/.github/workflows/jekyll-build.yml deleted file mode 100644 index e70385484e..0000000000 --- a/.github/workflows/jekyll-build.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Jekyll Build Verification - -on: [pull_request] - -jobs: - check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - run: | - JEKYLL_FATAL_LINK_CHECKER=internal bundle exec jekyll build --future diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml deleted file mode 100644 index 1940a03581..0000000000 --- a/.github/workflows/link-checker.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Check Links -on: - workflow_dispatch: - schedule: - - cron: "30 11 * * 0" -jobs: - check: - if: github.repository == ‘opensearch-project/documentation-website’ - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - run: | - JEKYLL_FATAL_LINK_CHECKER=all bundle exec jekyll build --future - - name: Create Issue On Build Failure - if: ${{ failure() }} - uses: dblock/create-a-github-issue@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - with: - update_existing: true - filename: .github/ISSUE_TEMPLATE/broken_links.md diff --git a/.github/workflows/publish_site.yml b/.github/workflows/publish_site.yml new file mode 100644 index 0000000000..6f809101ed --- /dev/null +++ b/.github/workflows/publish_site.yml @@ -0,0 +1,97 @@ +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' + +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 + outputs: + version: ${{ steps.config.outputs.version }} + output2: ${{ steps.step2.outputs.test }} + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ needs.setup.outputs.ruby-version }} + bundler-cache: true + - id: config + name: Update _config.yml + run: | + sed -i '/^url:/c\url: "https://${{ env.WEBSITE_URL }}"' _config.yml + WEBSITE_VERSION=$(cat _config.yml|grep "^opensearch_major_minor_version:"|cut -d ':' -f2| tr -d '[:blank:]') + echo "version=$WEBSITE_VERSION" >> $GITHUB_OUTPUT + sed -i '/^baseurl:/c\baseurl: "/docs/'"$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/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SFTP_SSH_PRIVATE_KEY }} + + - name: Upload Folder + run: | + sudo apt install lftp -y + lftp --version + WEBSITE_VERSION=${{ needs.build.outputs.version }} + if [ -z "$WEBSITE_VERSION" ]; then + echo "WEBSITE_VERSION is empty" + exit 1 + fi + echo "Start SFTP upload version: $WEBSITE_VERSION" + lftp -u ${{ secrets.SFTP_USERNAME }}, -e "set sftp:connect-program 'ssh -a -x -o StrictHostKeyChecking=no'; mkdir -p /var/www/${{ env.WEBSITE_URL }}/html/$WEBSITE_VERSION; mirror --reverse --parallel=20 --verbose _site/ /var/www/${{ env.WEBSITE_URL }}/html/$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 diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000000..77470cb39f --- /dev/null +++ b/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file