Testing smart contracts #3782
Workflow file for this run
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: Docusaurus CICD | |
env: | |
prod_pages_fqdn: ${{ vars.PROD_PAGES_FQDN }} | |
selected_node_version: 16.14 | |
on: | |
push: | |
branches: | |
- dev | |
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@v4 | |
with: | |
name: gh-pages-backup | |
path: . | |
build: | |
runs-on: ubuntu-latest | |
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 - production | |
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: Template credentials - preview | |
if: github.event_name == 'pull_request' | |
uses: cuchi/jinja2-action@1149b92d9ea6db61d7f71c22e3d5028d8065f140 | |
with: | |
template: .github/templates/.env.production.j2 | |
output_file: .env.production | |
env: | |
DIRECTUS_URL: ${{ secrets.PREVIEW_DIRECTUS_URL }} | |
DIRECTUS_GRAPHQL_URL: ${{ secrets.PREVIEW_DIRECTUS_GRAPHQL_URL }} | |
DIRECTUS_TOKEN: ${{ secrets.PREVIEW_DIRECTUS_TOKEN }} | |
SITE_URL: ${{ vars.SITE_URL }} | |
BASE_URL: ${{ vars.BASE_URL }} | |
- name: Yarn install | |
run: | | |
yarn install | |
- name: Run code analysis | |
run: | | |
yarn format | |
- 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@v4 | |
with: | |
name: gh-pages-depl-payload | |
path: ./docs | |
validate-external-links: | |
needs: build | |
runs-on: ubuntu-latest | |
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: Yarn install | |
run: | | |
yarn install | |
- name: Validate external links | |
run: | | |
yarn check:externals | |
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-preview: | |
if: github.event_name == 'pull_request' | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@master | |
with: | |
name: gh-pages-depl-payload | |
path: ./docs | |
- name: Deploy to Netlify | |
uses: nwtgck/[email protected] | |
with: | |
publish-dir: 'docs' | |
production-deploy: false | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
deploy-message: ${{ github.event.pull_request.title }} | |
enable-pull-request-comment: true | |
enable-commit-comment: false | |
enable-github-deployment: false | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.PREVIEW_NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.PREVIEW_NETLIFY_SITE_ID }} | |
timeout-minutes: 1 | |
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 |