Skip to content

Commit

Permalink
feat: add update-only-version param (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored Feb 27, 2025
1 parent cefbb32 commit e53c0e9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This GitHub action registers new stable version of documentation.
- `storage-access-key-id` (required) - The access key ID associated with the account that has permission to access and upload to the specified storage bucket.
- `storage-secret-access-key` (required) - The secret access key associated with the account.
- `version` (default: empty string) - The documentation version name.
- `update-only-version` (default: 'false') - Specifies whether to update the version information without updating the head. Set it to 'true' if only the version should be updated.
- `server` (default: 'https://viewer.diplodoc.com') - The root URL of the server.

## Usage
Expand Down Expand Up @@ -73,6 +74,7 @@ jobs:
### Release version
Basic example, the head and version number will be updated:
```yaml
name: Release tag

Expand All @@ -98,6 +100,57 @@ jobs:
storage-secret-access-key: ${{ secrets.DIPLODOC_SECRET_ACCESS_KEY }}
```
Advanced usage, you can choose releases of which branch will be considered default and will be updated together with the head, and in which releases only the version will be updated.
```yaml
name: Release tag

on:
push:
branches:
- 'main'
- 'stable-**'
paths:
- 'docs/**'
workflow_dispatch:

jobs:
<...>
release:
needs: upload
runs-on: ubuntu-latest
concurrency:
group: release-documentation-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Extract version
shell: bash
run: echo "version=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | sed -e 's|stable-|v|g' -e 's|-|.|g' >> $GITHUB_OUTPUT
id: extract_version

- name: Set Default Version
id: set-default-version
shell: bash
env:
DEFAULT_VERSION: "main"
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" == "$DEFAULT_VERSION" ]]; then
echo "UPDATE_ONLY_VERSION=false" >> $GITHUB_ENV
else
echo "UPDATE_ONLY_VERSION=true" >> $GITHUB_ENV
fi
- name: Release
uses: diplodoc-platform/docs-release-action@v2
with:
revision: "${{ github.sha }}"
version: "${{ steps.extract_version.outputs.version }}"
storage-bucket: ${{ secrets.DOCS_PROJECT_NAME }}
storage-access-key-id: ${{ secrets.DOCS_AWS_KEY_ID }}
storage-secret-access-key: ${{ secrets.DOCS_AWS_SECRET_ACCESS_KEY }}
update-only-version: "${{ env.UPDATE_ONLY_VERSION }}"
```
### Release on custom server
```yaml
Expand Down
14 changes: 11 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,32 @@ inputs:
required: true
version:
default: ""
update-only-version:
required: false
default: "false"
server:
default: "https://viewer.diplodoc.com"

runs:
using: composite
steps:
- name: Update head
- name: Update version or head
shell: bash
run: |
set -e
ENDPOINT="head"
if [[ "${{ inputs.update-only-version }}" == "true" ]]; then
ENDPOINT="versions"
fi
RESPONSE_CODE=$(curl \
--header "Content-Type: application/json" \
--silent \
--output RESPONSE \
--write-out "%{http_code}" \
--data-binary @- \
${{ inputs.server }}/_/api/head <<< $(jq -c -n '{
${{ inputs.server }}/_/api/$ENDPOINT <<< $(jq -c -n '{
revision:"${{ inputs.revision }}",
version:"${{ inputs.version }}",
project:"${{ inputs.storage-bucket }}",
Expand Down

0 comments on commit e53c0e9

Please sign in to comment.