Skip to content

Commit

Permalink
ci: fix error in docs step
Browse files Browse the repository at this point in the history
  • Loading branch information
k3rn31 committed Aug 7, 2022
1 parent 99d26f6 commit 13315ed
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 56 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,5 @@ jobs:
needs: test
uses: ./.github/workflows/docs.yml
with:
short_version: next
full_version: x.y.z
default: false
version: "next"

53 changes: 31 additions & 22 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@ name: Documentation
on:
workflow_call:
inputs:
short_version:
description: The version in the format vX.Y
required: true
type: string
full_version:
description: The full version in the X.Y.Z format
required: false
type: string
default: x.y.z
label:
description: The alias for the documentation
version:
description: The version tag (v0.1.2)
required: false
type: string
default:
description: Is this the default documentation?
required: false
type: boolean

jobs:
documentation:
Expand All @@ -28,11 +15,10 @@ jobs:
contents: write
runs-on: ubuntu-latest
env:
GR_VERSION: ${{ inputs.full_version }}
GR_SHORT_VERSION: ${{ inputs.short_version }}
GR_VERSION_TAG: ${{ inputs.version }}
if: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: actions/setup-python@v4
Expand All @@ -47,11 +33,34 @@ jobs:
mkdocs-material \
mkdocs-macros-plugin \
mike
- run: |
mike deploy --update-aliases --push ${{ inputs.short_version }} ${{ inputs.label }}
- name: Set version env
if: ${{ env.GR_VERSION_TAG != 'next' }}
# v1.2.3 ->
# GR_FULL_VERSION=1.2.3
# GR_SHORT_VERSION=1.2
# GR_PATCH_VERSION=2
run: |
echo "GR_FULL_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -c2-)" >> $GITHUB_ENV
echo "GR_SHORT_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -d '.' -f 1,2 | cut -c2-)" >> $GITHUB_ENV
echo "GR_PATCH_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -d '.' -f 3)" >> $GITHUB_ENV
# If it is a major or minor, we mark it as latest and default.
- if: ${{ env.GR_PATCH_VERSION == '0' && env.GR_VERSION_TAG != 'next' }}
run: |
mike deploy --update-aliases --push ${{ env.GR_SHORT_VERSION }} latest
mike list
working-directory: docs
# If it is a patch, we don't set it at latest
- if: ${{ env.GR_PATCH_VERSION != '0' && env.GR_VERSION_TAG != 'next' }}
run: |
mike deploy --update-aliases --push ${{ env.GR_SHORT_VERSION }}
mike list
working-directory: docs
- if: ${{ env.GR_VERSION_TAG == 'next' }}
run: |
mike deploy --update-aliases --push next
mike list
working-directory: docs
- run: |
mike set-default ${{ inputs.label }}
if: ${{ inputs.default == true }}
mike set-default --push latest
mike list
working-directory: docs
36 changes: 6 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch all tags
Expand All @@ -40,33 +40,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }}
documentation:
runs-on: ubuntu-latest
name: Build documentation
if: ${{ github.event_name != 'pull_request' }}
needs: [ goreleaser ]
steps:
- name: Set version env
# v1.2.3 ->
# GR_FULL_VERSION=1.2.3
# GR_SHORT_VERSION=v1.2
# GR_PATCH_VERSION=2
run: |
echo "GR_FULL_VERSION=$(echo $GITHUB_REF | cut -c2-)" >> $GITHUB_ENV
echo "GR_SHORT_VERSION=$(echo $GITHUB_REF | cut -d '.' -f 1,2 | cut -c2-)" >> $GITHUB_ENV
echo "GR_PATCH_VERSION=$(echo $GITHUB_REF | cut -d '.' -f 3)" >> $GITHUB_ENV
- name: Build latest documentation
# If patch is 0, it is a new release; set as new default
if: ${{ env.GR_PATCH_VERSION == '0' }}
uses: ./.github/workflows/docs.yml
with:
short_version: ${{ env.GR_SHORT_VERSION }}
full_version: ${{ env.GR_FULL_VERSION }}
label: latest
default: true
- name: Build patch documentation
# If patch is not 0, it is a patch release; don't set as default
if: ${{ env.GR_PATCH_VERSION != '0' }}
uses: ./.github/workflows/docs.yml
with:
short_version: ${{ env.GR_SHORT_VERSION }}
full_version: ${{ env.GR_FULL_VERSION }}
default: false
needs: goreleaser
uses: ./.github/workflows/docs.yml
with:
version: ${{ github.ref }}
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extra:
version:
provider: mike
release:
full_version: !ENV [GR_VERSION, 'X.Y.Z']
full_version: !ENV [GR_FULL_VERSION, 'X.Y.Z']
short_version: !ENV [GR_SHORT_VERSION, 'X.Y']

nav:
Expand Down

0 comments on commit 13315ed

Please sign in to comment.