Skip to content

[DRAFT] Auto publish pr docs #829

[DRAFT] Auto publish pr docs

[DRAFT] Auto publish pr docs #829

Workflow file for this run

name: Continuous Integration
on:
pull_request:
workflow_dispatch:
release:
types: [published]
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
# build-test:
# strategy:
# fail-fast: true
# matrix:
# os: [ubuntu-latest, macos-latest, macos-13, windows-latest, ubuntu-arm]
# include:
# - os: ubuntu-latest
# checkGenCodeTarget: true
# cloudTestTarget: true
# - os: ubuntu-arm
# runsOn: buildjet-4vcpu-ubuntu-2204-arm
# runs-on: ${{ matrix.runsOn || matrix.os }}
# env:
# # We can't check this directly in the cloud test's `if:` condition below,
# # so we have to check it here and report it in an env variable.
# HAS_SECRETS: ${{ secrets.TEMPORAL_CLIENT_CERT != '' && secrets.TEMPORAL_CLIENT_KEY != '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
path: cli
submodules: recursive
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
- name: Checkout docs repo
uses: actions/checkout@v4
with:
repository: temporalio/documentation
token: ${{ steps.generate_token.outputs.token }}
path: docs
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Generate CLI docs
run: |
cd cli/temporalcli/internal/cmd/gen-docs
go run .
- name: Publish generated docs to documentation repo
# - name: Test cloud
# if: ${{ matrix.cloudTestTarget && env.HAS_SECRETS == 'true' }}
# env:
# TEMPORAL_ADDRESS: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}.tmprl.cloud:7233
# TEMPORAL_NAMESPACE: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }}
# TEMPORAL_TLS_CERT: client.crt
# TEMPORAL_TLS_CERT_CONTENT: ${{ secrets.TEMPORAL_CLIENT_CERT }}
# TEMPORAL_TLS_KEY: client.key
# TEMPORAL_TLS_KEY_CONTENT: ${{ secrets.TEMPORAL_CLIENT_KEY }}
# shell: bash
run: |
set -e
set -x
BRANCH_NAME="cli-update-docs-${{ github.ref_name }}"
cd docs
# TODO: replace yuandrew with ${{ github.event.release.author.login }}
# can this not be done until we "release"?
# Query the GitHub API for the release author
API_RESPONSE=$(curl -s -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \
https://api.github.com/users/yuandrew)
# Extract the email field from the API response
AUTHOR_LOGIN=$(echo "$API_RESPONSE" | jq -r '.author.login')
echo "author_login: $AUTHOR_LOGIN"
EMAIL=$(echo "$API_RESPONSE" | jq -r '.author.email')
echo "EMAIL: $EMAIL"
EMAIL=$(echo "$API_RESPONSE" | jq -r '.email')
echo "EMAIL: $EMAIL"
# If no public email is found, fallback to a default
if [ "$EMAIL" == "null" ]; then
echo "falling back on default email"
EMAIL="andrew.yuan@temporal.io"
# TODO: sdk@temporal.io
fi
# Setup the committers identity.
git config --global user.email "$EMAIL"
git config --global user.name "yuandrew"
git checkout -b $BRANCH_NAME
cp ../cli/temporalcli/docs/*.mdx docs/cli/
git add .
# TODO: mention CLI release version
git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}"
git push origin $BRANCH_NAME
gh pr create \
--body "Autogenerated PR from https://github.com/temporalio/cli" \
--title "CLI docs update $LATEST_TAG" \
--head "$BRANCH_NAME" \
--base "main"