Introduce bond and the hard way tutorials #652
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: CICD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
pull_request: | |
env: | |
MKDOCS_MATERIAL_VER: 9.5.19-insiders-4.53.8-hellt | |
jobs: | |
docs-test: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- run: docker run -v $(pwd):/docs --entrypoint mkdocs ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_MATERIAL_VER build --clean --strict | |
- name: Cache htmltest external links | |
id: cache-htmltest | |
uses: actions/cache@v4 | |
with: | |
path: tmp/.htmltest | |
# key will contain hash of all md files to check if files have changed | |
# when files are changed, a new key name is formed, and thus a new cache will be saved | |
key: htmltest-${{ hashFiles('docs/**/*.md') }} | |
# the restore key will fetch any previously saved cache even if there is no match on key | |
# this allows to use cache from prev runs and update it | |
restore-keys: | | |
htmltest- | |
- name: htmltest | |
uses: wjdp/htmltest-action@master | |
with: | |
config: docs/htmltest.yml | |
# this action deploys mkdocs-material to gh-pages. It is commented out because we moved to cloudflare pages | |
# publish-docs-gh-pages: | |
# runs-on: ubuntu-20.04 | |
# if: startsWith(github.ref, 'refs/heads/main') | |
# needs: docs-test | |
# steps: | |
# # this is to mitigate unsafe dir errors from git | |
# # https://github.com/actions/checkout/issues/760 | |
# - name: Add workspace as safe directory | |
# run: | | |
# git config --global --add safe.directory /__w/learn-srlinux/learn-srlinux | |
# - name: Checkout | |
# uses: actions/checkout@v3 | |
# with: | |
# fetch-depth: 0 | |
# - name: Login to GitHub Container Registry | |
# uses: docker/login-action@v1 | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
# - run: docker run -v $(pwd):/docs --entrypoint ash ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_MATERIAL_VER -c 'git config --global --add safe.directory /docs; mkdocs gh-deploy --force' | |
publish-docs: | |
runs-on: ubuntu-22.04 | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # needed for commit authors plugin | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build docs | |
run: | | |
docker run --env CI=true --env MKDOCS_GIT_COMMITTERS_APIKEY=${{ secrets.GITHUB_TOKEN }} -v $(pwd):/docs --user $(id -u):$(id -g) --entrypoint mkdocs ghcr.io/srl-labs/mkdocs-material-insiders:$MKDOCS_MATERIAL_VER build | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/wrangler-action@v3 | |
id: wrangler-deploy | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: 62e7f50db0ad5b34dbf1fb9b0ed2ef81 | |
command: pages deploy site --project-name=learn-srlinux --branch=${{ env.BRANCH_NAME }} | |
- name: Add deploy comment to PR | |
uses: actions/github-script@v7 | |
if: github.event_name == 'pull_request' | |
with: | |
script: | | |
const branchName = process.env.BRANCH_NAME.replace(/\./g, '-'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `✨ deployed to ${{ steps.wrangler-deploy.outputs.deployment-url }} and https://${branchName}.learn-srlinux.pages.dev` | |
}) |