Skip to content

Commit

Permalink
Merge pull request #517 from k8up-io/auto-docs
Browse files Browse the repository at this point in the history
Automate the release of documentation for Antora
  • Loading branch information
ccremer authored Sep 21, 2021
2 parents 20e244c + e67cbe9 commit e09b5bc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docs

on:
push:
tags:
- "*"

jobs:
antora:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'tags') }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "Antora via GitHub Actions"
git config user.email "actions@github.com"
- name: Parse semver string
id: semver
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.ref }}
version_extractor_regex: '\/v(.*)$'
- name: Set variables
run: |
echo "MINOR_VERSION=${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}" >> $GITHUB_ENV
echo "BRANCH_NAME=docs/v${{ steps.semver.outputs.major }}.${{ steps.semver.outputs.minor }}" >> $GITHUB_ENV
- name: Set branch name for Prerelease
if: ${{ steps.semver.outputs.prerelease != '' }}
run: echo "BRANCH_NAME=${{ env.BRANCH_NAME }}-rc" >> $GITHUB_ENV

- name: Checkout remote branch if exists
run: git checkout ${{ env.BRANCH_NAME }}
continue-on-error: true
- name: Rebase if possible
run: git rebase ${GITHUB_REF##*/} ${{ env.BRANCH_NAME }}
continue-on-error: true
- name: Create new branch if not existing
run: git switch --create ${{ env.BRANCH_NAME }}
continue-on-error: true

- name: Patch Antora file for Release
run: yq eval 'del(.prerelease) | del (.display_version) | .version = "${{ env.MINOR_VERSION }}"' -i docs/antora.yml
if: ${{ steps.semver.outputs.prerelease == '' }}
- name: Patch Antora file for Prerelease
run: yq eval 'del (.display_version) | .version = "${{ env.MINOR_VERSION }}", .prerelease = "-${{ steps.semver.outputs.prerelease }}"' -i docs/antora.yml
if: ${{ steps.semver.outputs.prerelease != '' }}

- name: Commit
run: git commit -all --message "Update version for Antora"
continue-on-error: true
- name: Push
run: git push --atomic --force --set-upstream origin ${{ env.BRANCH_NAME }}

- name: Cleanup prerelease branch if existing
if: ${{ steps.semver.outputs.prerelease == '' }}
run: git push origin --delete ${{ env.BRANCH_NAME }}-rc
continue-on-error: true
4 changes: 1 addition & 3 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
* xref:index.adoc[Home]
ifeval::['{page-origin-reftype}' == 'tag']
* https://github.com/k8up-io/k8up/releases/tag/{page-origin-refname}[Changelog,window=_blank]
endif::[]
* https://github.com/k8up-io/k8up/releases[Changelog,window=_blank]
.Tutorials
* xref:tutorials/tutorial.adoc[Introduction]
Expand Down

0 comments on commit e09b5bc

Please sign in to comment.