Update Documentation #123
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 Documentation" | |
on: | |
workflow_dispatch: | |
# Start only after Build was finished | |
workflow_run: | |
workflows: [Build] | |
branches: [main] | |
types: [completed] | |
jobs: | |
check-hsmcpp-version: | |
# only run for successful build after push event | |
# avoid running this action on forks | |
if: ${{ (github.repository == 'igor-krechetov/hsmcpp') && ((github.event.workflow_run == null) || ((github.event.workflow_run.conclusion == 'success') && (github.event.workflow_run.event == 'push'))) }} | |
runs-on: ubuntu-latest | |
outputs: | |
commit_version: ${{ steps.get_version.outputs.commit_version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/workflows/get-commit-version | |
id: get_version | |
with: | |
repo_dir: ${{ env.GITHUB_WORKSPACE }} | |
commit_sha: ${{ github.event.workflow_run.head_sha }} | |
update-doc-src: | |
runs-on: ubuntu-latest | |
needs: check-hsmcpp-version | |
# only run for commits which have version defined | |
if: ${{ needs.check-hsmcpp-version.outputs.commit_version != '' }} | |
env: | |
target_dir: './hsmcpp_doc' | |
steps: | |
# checkout docs repository | |
- uses: actions/checkout@v3 | |
with: | |
repository: 'igor-krechetov/hsmcpp-doc' | |
token: ${{ secrets.HSMCPP_BOT_TOKEN }} | |
ref: main | |
submodules: 'recursive' | |
path: ${{ env.target_dir }} | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v5 | |
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 | |
workdir: ${{ env.target_dir }} | |
- name: Update to latest hsmcpp | |
run: | | |
cd ${{ env.target_dir }} | |
git submodule foreach git fetch --all | |
git submodule foreach git reset --hard origin/main | |
git add ./source/hsmcpp | |
# Update documentation only if commit had version defined | |
- name: Update documentation | |
run: | | |
cd ${{ env.target_dir }} | |
echo "Found new hsmcpp version '${{ needs.check-hsmcpp-version.outputs.commit_version }}'" | |
git commit -S -am "[auto] hsmcpp library updated to ${{ needs.check-hsmcpp-version.outputs.commit_version }}" | |
git push |