Skip to content

Merge pull request #1245 from casper-network/backport-light-theme #3462

Merge pull request #1245 from casper-network/backport-light-theme

Merge pull request #1245 from casper-network/backport-light-theme #3462

Workflow file for this run

name: Docusaurus CICD
env:
prod_pages_fqdn: ${{ vars.PROD_PAGES_FQDN }}
on:
push:
branches: "*"
pull_request:
types: [ opened, reopened, synchronize ]
jobs:
backup:
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- uses: actions/upload-artifact@v3
with:
name: gh-pages-backup
path: .
build:
runs-on: ubuntu-latest
env:
selected_node_version: 16.14
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ env.selected_node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.selected_node_version }}
cache: yarn
- name: Template credentials
if: github.ref == 'refs/heads/dev'
uses: cuchi/jinja2-action@1149b92d9ea6db61d7f71c22e3d5028d8065f140
with:
template: .github/templates/.env.production.j2
output_file: .env.production
env:
ALGOLIA_APP_ID: ${{ vars.ALGOLIA_APP_ID }}
ALGOLIA_INDEX_NAME: ${{ vars.ALGOLIA_INDEX_NAME }}
ALGOLIA_API_KEY: ${{ vars.ALGOLIA_API_KEY }}
CROWDIN_PERSONAL_ACCESS_TOKEN: ""
GOOGLE_TAG_ANONYMIZE_IP: ${{ vars.GOOGLE_TAG_ANONYMIZE_IP }}
GOOGLE_TAG_TRACKING_ID: ${{ vars.GOOGLE_TAG_TRACKING_ID }}
GOOGLE_TAG_MANAGER_ID: ${{ vars.GOOGLE_TAG_MANAGER_ID }}
DIRECTUS_URL: ${{ secrets.DIRECTUS_URL }}
DIRECTUS_GRAPHQL_URL: ${{ secrets.DIRECTUS_GRAPHQL_URL }}
DIRECTUS_TOKEN: ${{ secrets.DIRECTUS_TOKEN }}
SITE_URL: ${{ vars.SITE_URL }}
ALGOLIA_SITE_APP_ID: ${{ vars.ALGOLIA_SITE_APP_ID }}
ALGOLIA_SITE_API_KEY: ${{ vars.ALGOLIA_SITE_API_KEY }}
ALGOLIA_SITE_INDEX_NAME: ${{ vars.ALGOLIA_SITE_INDEX_NAME }}
BASE_URL: ${{ vars.BASE_URL }}
- name: Yarn install
run: |
yarn install
- name: Run code analysis
run: |
yarn format
- name: Validate external links
run: |
yarn check:externals
- name: Clear Docusaurus cache
run: |
yarn clear
- name: Build app
run: |
yarn build --out-dir ./docs
env:
NODE_ENV: production
- name: Add CNAME file to the build output payload to keep the custom domain settings of GitHub Pages enabled
run: |
echo "$prod_pages_fqdn" > ./docs/CNAME
- uses: actions/upload-artifact@v3
with:
name: gh-pages-depl-payload
path: ./docs
system-tests-predeployment:
needs: build
runs-on: ubuntu-latest
steps:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Install Jekyll
run: |
sudo gem install jekyll
- uses: actions/download-artifact@master
with:
name: gh-pages-depl-payload
path: ./docs
- name: Create Jekyll site
run: |
jekyll new --skip-bundle --force .
working-directory: ./docs
- name: Edit GemFile
run: |
sed -i 's/^gem "jekyll", .*$/gem "github-pages", "~> 219", group: :jekyll_plugins/' Gemfile
working-directory: ./docs
- name: Run bundle install
run: |
bundle install
working-directory: ./docs
- name: Edit baseurl in _config.yml
run: |
sed -i 's/^baseurl.*$/baseurl: "\/"/' _config.yml
working-directory: ./docs
- name: Run Jekyll site locally and test
run: |
echo "Serve Jekyll site"
bundle exec jekyll serve &
while ! nc -z 127.0.0.1 4000; do
sleep 0.1
done
echo "Jekyll site is up..."
echo "Testing if homepage responds correctly"
curl --fail http://127.0.0.1:4000/
echo "Testing if a page responds correctly"
curl --fail http://127.0.0.1:4000/operators/setup-network/chain-spec/
echo "Testing if a page responds correctly"
curl --fail http://127.0.0.1:4000/concepts/serialization-standard/
working-directory: ./docs
deploy-prod:
if: ${{ github.ref == 'refs/heads/dev' && github.repository == 'casper-network/docs' }}
needs: [backup, system-tests-predeployment]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: gh-pages-depl-payload
path: ./docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
- name: Wait some time to make sure deployment is finished
run: |
sleep 60
system-tests-postdeployment-prod:
needs: deploy-prod
runs-on: ubuntu-latest
steps:
- name: Test home page
run: |
echo "Testing if homepage responds correctly"
curl --fail https://$prod_pages_fqdn
- name: Test a random page
run: |
echo "Testing if a page responds correctly"
curl --fail https://$prod_pages_fqdn/operators/setup-network/chain-spec
- name: Test another random page
run: |
echo "Testing if a page responds correctly"
curl --fail https://$prod_pages_fqdn/concepts/serialization-standard
rollback-if-tests-fail-prod:
if: ${{ always() && (needs.system-tests-postdeployment-prod.result=='failure') }}
needs: system-tests-postdeployment-prod
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: gh-pages-backup
path: ./docs
- name: Deploy the previous version to Github Pages
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs