Update versioned docs #1570
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: Update versioned docs | |
concurrency: | |
group: update-docs-${{ github.ref }}-${{ github.event.inputs.section }} | |
cancel-in-progress: ${{ github.event.inputs.draft == 'true' }} | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "New docs version (repository tag or repository ref)" | |
required: true | |
repository: | |
description: "Set the repository that docs has been updated (axone-protocol/contracts | axone-protocol/axoned)" | |
required: true | |
section: | |
description: "Which section will be update (contracts | modules | commands | predicates)" | |
required: true | |
docs_directory: | |
description: "On which directory documentation is located (docs/* | docs/proto/* | docs/command/*)" | |
required: false | |
default: "docs/*" | |
draft: | |
type: boolean | |
description: "Indicate if the publication of the documentation should be kept in draft and no new version should be released" | |
required: false | |
default: false | |
jobs: | |
update-versioned-doc: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.OPS_TOKEN }} | |
fetch-depth: 2 | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.version }} | |
repository: ${{ github.event.inputs.repository }} | |
token: ${{ secrets.OPS_TOKEN }} | |
path: tmp | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }} | |
git_config_global: true | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Copy updated docs | |
run: | | |
rm -rf ${{ github.event.inputs.section }}/* | |
rsync -rmv --include='*/' --include='*.md' --include='*.mdx' --include='*.json' --exclude='*' tmp/${{ github.event.inputs.docs_directory }} ${{ github.event.inputs.section }} | |
git rm --ignore-unmatch --cached tmp | |
rm -rf .git/modules/tmp | |
rm -rf tmp | |
- name: Setup node environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.18 | |
cache: yarn | |
- name: Bump new version | |
if: ${{ github.event.inputs.draft == 'false' }} | |
run: | | |
yarn | |
yarn run docusaurus docs:version:${{ github.event.inputs.section }} ${{ github.event.inputs.version }} | |
- name: Search for all modified files that involve the creation of PR or commit to main | |
id: changed-files | |
uses: tj-actions/[email protected] | |
with: | |
files: | | |
*.json | |
*.md | |
- name: Commit documentation draft | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
if: ${{ github.event.inputs.draft == 'true' && steps.changed-files.outputs.any_changed }} | |
with: | |
commit_user_name: ${{ vars.BOT_GIT_COMMITTER_NAME }} | |
commit_user_email: ${{ vars.BOT_GIT_COMMITTER_EMAIL }} | |
commit_author: ${{ vars.BOT_GIT_AUTHOR_NAME }} <${{ vars.BOT_GIT_AUTHOR_EMAIL }}> | |
commit_message: "feat(${{ github.event.inputs.section }}): update ${{ github.event.inputs.repository }} ${{ github.event.inputs.section }} documentation" | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v7 | |
if: ${{ github.event.inputs.draft == 'false' && steps.changed-files.outputs.any_changed }} | |
with: | |
token: ${{ secrets.OPS_TOKEN }} | |
commit-message: "feat(${{ github.event.inputs.section }}): add ${{ github.event.inputs.repository }} ${{ github.event.inputs.version }} ${{ github.event.inputs.section }} documentation" | |
committer: ${{ vars.BOT_GIT_AUTHOR_NAME }} <${{ vars.BOT_GIT_AUTHOR_EMAIL }}> | |
author: ${{ vars.BOT_GIT_AUTHOR_NAME }} <${{ vars.BOT_GIT_AUTHOR_EMAIL }}> | |
branch: feat/${{ github.event.inputs.section }}-${{ github.event.inputs.version }} | |
title: 📜 Add ${{ github.event.inputs.version }} ${{ github.event.inputs.section }} documentation version | |
body: | | |
#### 📜 Documentation update | |
🎉 A new version of [${{ github.event.inputs.repository }}](https://github.com/${{ github.event.inputs.repository }}/releases/tag/${{ github.event.inputs.version }}) is available. | |
This PR add this new `${{ github.event.inputs.version }}` version into the documentation. | |
labels: documentation | |
assignees: ccamel,amimart | |
reviewers: ccamel,amimart | |
add-paths: | | |
*.json | |
*.md |