From b8104de66b5407bda892bce5a594971d24688cf7 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 13:33:05 -0700 Subject: [PATCH 01/36] test PR publishing, generate token --- .github/workflows/ci.yaml | 132 ++++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dec27bbdf..d9d072c7c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,72 +1,94 @@ name: Continuous Integration on: pull_request: - push: - branches: - - main - + workflow_dispatch: + release: + types: [published] jobs: - 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 != '' }} + update: + runs-on: ubuntu-latest + permissions: + contents: write + defaults: + run: + shell: bash steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v2 with: + path: cli submodules: recursive - - name: Setup Go - uses: actions/setup-go@v5 + - name: Generate token + id: generate_token + uses: actions/create-github-app-token@v1 with: - go-version-file: 'go.mod' - - - name: Install gotestsum - run: go install gotest.tools/gotestsum@latest - - - name: Create junit-xml directory - run: mkdir junit-xml + app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} + private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} - - name: Test - run: gotestsum --junitfile junit-xml/${{matrix.os}}.xml -- ./... + - name: Checkout docs repo + uses: actions/checkout@v4 + with: + repository: temporalio/documentation + token: ${{ steps.generate_token.outputs.token }} + path: docs - - name: 'Upload junit-xml artifacts' - uses: actions/upload-artifact@v4 - if: always() + - name: Setup Go + uses: actions/setup-go@v4 with: - name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{matrix.os}} - path: junit-xml - retention-days: 14 + go-version: '1.22' - - name: Regen code, confirm unchanged - if: ${{ matrix.checkGenCodeTarget }} + - name: Generate CLI docs run: | - go run ./temporalcli/internal/cmd/gen-commands - git diff --exit-code + cd cli/temporalcli/internal/cmd/gen-docs + go run . - - 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 + - name: Publish generated docs to documentation repo run: | - printf '%s\n' "$TEMPORAL_TLS_CERT_CONTENT" >> client.crt - printf '%s\n' "$TEMPORAL_TLS_KEY_CONTENT" >> client.key - go run ./cmd/temporal workflow list --limit 2 + 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" From 50fbaa29c563f1f5846b60dbf1000048b935aa7c Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 13:50:42 -0700 Subject: [PATCH 02/36] remove /merge from branch name --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d9d072c7c..6550eb662 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,6 +49,9 @@ jobs: set -x BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" + # Remove the "/merge" suffix if it exists + BRANCH_NAME=${BRANCH_NAME%/merge} + echo "Branch name: $BRANCH_NAME" cd docs From 980a25bbfc28ece85eb02bacd064168f95516b4d Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 13:57:13 -0700 Subject: [PATCH 03/36] set git permission --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6550eb662..7e6a5787b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -80,6 +80,7 @@ jobs: # Setup the committers identity. git config --global user.email "$EMAIL" git config --global user.name "yuandrew" + git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ From e969fb80d3c3289e3e3adb58519c30ab0614c2ce Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 14:01:04 -0700 Subject: [PATCH 04/36] Persist credentials --- .github/workflows/ci.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e6a5787b..efa97954b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: shell: bash steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: cli submodules: recursive @@ -30,6 +30,7 @@ jobs: uses: actions/checkout@v4 with: repository: temporalio/documentation + persist-credentials: true token: ${{ steps.generate_token.outputs.token }} path: docs @@ -80,7 +81,7 @@ jobs: # Setup the committers identity. git config --global user.email "$EMAIL" git config --global user.name "yuandrew" - git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git + # git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ From bdbf8c7fc43812d35a1e88971eb4ae74b0d12918 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 14:07:11 -0700 Subject: [PATCH 05/36] add GH_TOKEN in case that helps --- .github/workflows/ci.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index efa97954b..6c99eedfe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,6 +45,8 @@ jobs: go run . - name: Publish generated docs to documentation repo + env: + GH_TOKEN: ${{ github.generate_token.outputs.token }} run: | set -e set -x @@ -55,6 +57,7 @@ jobs: echo "Branch name: $BRANCH_NAME" cd docs + pwd # TODO: replace yuandrew with ${{ github.event.release.author.login }} # can this not be done until we "release"? @@ -88,7 +91,7 @@ jobs: 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 + git push origin "$BRANCH_NAME" From 103762b67f75f7afccb13f57a09ffe3cf8dc21c6 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 21 Mar 2025 14:20:40 -0700 Subject: [PATCH 06/36] clean up code --- .github/workflows/ci.yaml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c99eedfe..b1147576b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,31 +59,9 @@ jobs: cd docs pwd - # 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 config --global user.email "sdk@temporal.io" + git config --global user.name "Temporal CLI" # git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git git checkout -b $BRANCH_NAME From d12dc43632e3b2f2524720f08fb9517558088e49 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 25 Mar 2025 10:34:48 -0700 Subject: [PATCH 07/36] Try with pull-requests:write perms --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b1147576b..1abb97b5b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + pull-requests: write defaults: run: shell: bash From 7213de31ae31ba950d21ccd89b3f1c5c4271e81a Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 25 Mar 2025 10:50:47 -0700 Subject: [PATCH 08/36] Try with cli repo having token credentials too, why not? --- .github/workflows/ci.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1abb97b5b..8261545e6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,12 +14,6 @@ jobs: run: shell: bash steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - path: cli - submodules: recursive - - name: Generate token id: generate_token uses: actions/create-github-app-token@v1 @@ -27,6 +21,14 @@ jobs: app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} + - name: Checkout repository + uses: actions/checkout@v4 + with: + path: cli + submodules: recursive + persist-credentials: true + token: ${{ steps.generate_token.outputs.token }} + - name: Checkout docs repo uses: actions/checkout@v4 with: @@ -55,10 +57,8 @@ jobs: BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" # Remove the "/merge" suffix if it exists BRANCH_NAME=${BRANCH_NAME%/merge} - echo "Branch name: $BRANCH_NAME" cd docs - pwd # Setup the committers identity. git config --global user.email "sdk@temporal.io" From f45b73223ebd61e0195b53717400c582626a176b Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 25 Mar 2025 10:53:36 -0700 Subject: [PATCH 09/36] chatgpt suggestion, confirm token identity --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8261545e6..6b94c43ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -54,6 +54,8 @@ jobs: set -e set -x + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user + BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" # Remove the "/merge" suffix if it exists BRANCH_NAME=${BRANCH_NAME%/merge} From 26369bea37aa097c332ebfc179af8cc23c124c33 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Wed, 26 Mar 2025 13:00:57 -0700 Subject: [PATCH 10/36] repository-projects: write --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6b94c43ca..a29ecebe4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,7 @@ jobs: permissions: contents: write pull-requests: write + repository-projects: write defaults: run: shell: bash From 0f68b1012f245ca45052ed7174b6fca28dd72d49 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 15:47:26 -0700 Subject: [PATCH 11/36] Try to publish PR to CLI repo first --- .github/workflows/ci.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a29ecebe4..575500c12 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,6 +48,37 @@ jobs: cd cli/temporalcli/internal/cmd/gen-docs go run . + - name: Publish generated docs to cli repo + env: + GH_TOKEN: ${{ github.generate_token.outputs.token }} + run: | + set -e + set -x + + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user + + BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" + # Remove the "/merge" suffix if it exists + BRANCH_NAME=${BRANCH_NAME%/merge} + + cd cli + + # Setup the committers identity. + git config --global user.email "sdk@temporal.io" + git config --global user.name "Temporal CLI" + + git checkout -b $BRANCH_NAME + 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" + - name: Publish generated docs to documentation repo env: GH_TOKEN: ${{ github.generate_token.outputs.token }} From 312c08407c5557be2471909f6427e3b05711feec Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 15:56:03 -0700 Subject: [PATCH 12/36] print if GH_TOKEN is set, looks blank to me --- .github/workflows/ci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 575500c12..59aadcb4d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,6 +55,13 @@ jobs: set -e set -x + if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN is NOT set" + exit 1 + else + echo "GH_TOKEN is set" + fi + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" From 8a7ebde36216d5b8894696fd2ef30705acdb98db Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 15:58:00 -0700 Subject: [PATCH 13/36] I was using github.generate_token..... not steps.generate_token.... AHHHHHHH --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 59aadcb4d..114cead69 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,7 @@ jobs: - name: Publish generated docs to cli repo env: - GH_TOKEN: ${{ github.generate_token.outputs.token }} + GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | set -e set -x @@ -88,7 +88,7 @@ jobs: - name: Publish generated docs to documentation repo env: - GH_TOKEN: ${{ github.generate_token.outputs.token }} + GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | set -e set -x From cb2514312a9a2845f232a33c001c76e3970b611e Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:03:43 -0700 Subject: [PATCH 14/36] try docs repo --- .github/workflows/ci.yaml | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 114cead69..95c234657 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,44 +48,6 @@ jobs: cd cli/temporalcli/internal/cmd/gen-docs go run . - - name: Publish generated docs to cli repo - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} - run: | - set -e - set -x - - if [ -z "$GH_TOKEN" ]; then - echo "GH_TOKEN is NOT set" - exit 1 - else - echo "GH_TOKEN is set" - fi - - curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user - - BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" - # Remove the "/merge" suffix if it exists - BRANCH_NAME=${BRANCH_NAME%/merge} - - cd cli - - # Setup the committers identity. - git config --global user.email "sdk@temporal.io" - git config --global user.name "Temporal CLI" - - git checkout -b $BRANCH_NAME - 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" - - name: Publish generated docs to documentation repo env: GH_TOKEN: ${{ steps.generate_token.outputs.token }} From faa0b817afd2d9cb557f27eb4dc1b43023a55a80 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:09:15 -0700 Subject: [PATCH 15/36] jk, go back to trying CLI --- .github/workflows/ci.yaml | 49 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 95c234657..45366bfb6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,6 +48,45 @@ jobs: cd cli/temporalcli/internal/cmd/gen-docs go run . + - name: Publish generated docs to cli repo + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + set -e + set -x + + if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN is NOT set" + exit 1 + else + echo "GH_TOKEN is set" + fi + + + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user + + BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" + # Remove the "/merge" suffix if it exists + BRANCH_NAME=${BRANCH_NAME%/merge} + + cd cli + + # Setup the committers identity. + git config --global user.email "sdk@temporal.io" + git config --global user.name "Temporal CLI" + + git checkout -b $BRANCH_NAME + 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" + - name: Publish generated docs to documentation repo env: GH_TOKEN: ${{ steps.generate_token.outputs.token }} @@ -55,6 +94,13 @@ jobs: set -e set -x + if [ -z "$GH_TOKEN" ]; then + echo "GH_TOKEN is NOT set" + exit 1 + else + echo "GH_TOKEN is set" + fi + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" @@ -66,7 +112,6 @@ jobs: # Setup the committers identity. git config --global user.email "sdk@temporal.io" git config --global user.name "Temporal CLI" - # git remote set-url origin https://temporal-cicd:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ @@ -75,8 +120,6 @@ jobs: 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" \ From 481ee81474ae27f3af426b096aeb127c993766db Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:20:33 -0700 Subject: [PATCH 16/36] CLI works, go back to trying docs repo --- .github/workflows/ci.yaml | 43 +-------------------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 45366bfb6..80b8076c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,45 +48,6 @@ jobs: cd cli/temporalcli/internal/cmd/gen-docs go run . - - name: Publish generated docs to cli repo - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} - run: | - set -e - set -x - - if [ -z "$GH_TOKEN" ]; then - echo "GH_TOKEN is NOT set" - exit 1 - else - echo "GH_TOKEN is set" - fi - - - curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user - - BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" - # Remove the "/merge" suffix if it exists - BRANCH_NAME=${BRANCH_NAME%/merge} - - cd cli - - # Setup the committers identity. - git config --global user.email "sdk@temporal.io" - git config --global user.name "Temporal CLI" - - git checkout -b $BRANCH_NAME - 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" - - name: Publish generated docs to documentation repo env: GH_TOKEN: ${{ steps.generate_token.outputs.token }} @@ -101,8 +62,6 @@ jobs: echo "GH_TOKEN is set" fi - curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" https://api.github.com/user - BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" # Remove the "/merge" suffix if it exists BRANCH_NAME=${BRANCH_NAME%/merge} @@ -117,7 +76,7 @@ jobs: 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 commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}" --author ${{ github.actor }} git push origin "$BRANCH_NAME" gh pr create \ From 522c65e6236e3d9a5da571a39724986137fda1a7 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:26:08 -0700 Subject: [PATCH 17/36] try github get_user --- .github/workflows/ci.yaml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 80b8076c7..20fd81069 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -48,6 +48,18 @@ jobs: cd cli/temporalcli/internal/cmd/gen-docs go run . + - name: Get user info from GitHub API + id: get_user + run: | + curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/users/${{ github.actor }} > user.json + + name=$(jq -r .name user.json) + email="${{ github.actor }}@users.noreply.github.com" # fallback + + echo "git_name=$name" >> $GITHUB_OUTPUT + echo "git_email=$email" >> $GITHUB_OUTPUT + - name: Publish generated docs to documentation repo env: GH_TOKEN: ${{ steps.generate_token.outputs.token }} @@ -69,8 +81,13 @@ jobs: cd docs # Setup the committers identity. - git config --global user.email "sdk@temporal.io" - git config --global user.name "Temporal CLI" + #git config --global user.email "sdk@temporal.io" + #git config --global user.name "Temporal CLI" + + echo "${{ steps.get_user.outputs.git_name }}" + echo "${{ steps.get_user.outputs.git_email }}" + git config user.name "${{ steps.get_user.outputs.git_name }}" + git config user.email "${{ steps.get_user.outputs.git_email }}" git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ From b92f25f357fd58da52fe9f382dd1f1f32076d44f Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:26:46 -0700 Subject: [PATCH 18/36] try github get_user, remove author tag --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 20fd81069..0770c7177 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,7 +93,7 @@ jobs: 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 }}" --author ${{ github.actor }} + git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}" git push origin "$BRANCH_NAME" gh pr create \ From 04d91f5cd345857bfb1157ef1508c980268cb1bb Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:27:49 -0700 Subject: [PATCH 19/36] Try without GH_TOKEN --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0770c7177..428e62140 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -61,8 +61,8 @@ jobs: echo "git_email=$email" >> $GITHUB_OUTPUT - name: Publish generated docs to documentation repo - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} +# env: +# GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | set -e set -x From a33c660ccec30a60ecc75e0d04623116a9379e12 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:28:59 -0700 Subject: [PATCH 20/36] don't exit when GH_TOKEN isn't present --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 428e62140..8e6990db1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -69,7 +69,6 @@ jobs: if [ -z "$GH_TOKEN" ]; then echo "GH_TOKEN is NOT set" - exit 1 else echo "GH_TOKEN is set" fi From acd8afd51c626883c629206f9ef33dc32144c93f Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:31:16 -0700 Subject: [PATCH 21/36] don't checkout repo with token --- .github/workflows/ci.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8e6990db1..246bf1262 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,14 +28,14 @@ jobs: path: cli submodules: recursive persist-credentials: true - token: ${{ steps.generate_token.outputs.token }} +# token: ${{ steps.generate_token.outputs.token }} - name: Checkout docs repo uses: actions/checkout@v4 with: repository: temporalio/documentation persist-credentials: true - token: ${{ steps.generate_token.outputs.token }} +# token: ${{ steps.generate_token.outputs.token }} path: docs - name: Setup Go @@ -60,6 +60,7 @@ jobs: echo "git_name=$name" >> $GITHUB_OUTPUT echo "git_email=$email" >> $GITHUB_OUTPUT + - name: Publish generated docs to documentation repo # env: # GH_TOKEN: ${{ steps.generate_token.outputs.token }} From d05a843ae687196267845d0f74f6f051648b2694 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:44:21 -0700 Subject: [PATCH 22/36] try with git remote set-url origin --- .github/workflows/ci.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 246bf1262..b96980709 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,14 +28,14 @@ jobs: path: cli submodules: recursive persist-credentials: true -# token: ${{ steps.generate_token.outputs.token }} + token: ${{ steps.generate_token.outputs.token }} - name: Checkout docs repo uses: actions/checkout@v4 with: repository: temporalio/documentation persist-credentials: true -# token: ${{ steps.generate_token.outputs.token }} + token: ${{ steps.generate_token.outputs.token }} path: docs - name: Setup Go @@ -62,8 +62,8 @@ jobs: - name: Publish generated docs to documentation repo -# env: -# GH_TOKEN: ${{ steps.generate_token.outputs.token }} + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | set -e set -x @@ -88,6 +88,7 @@ jobs: echo "${{ steps.get_user.outputs.git_email }}" git config user.name "${{ steps.get_user.outputs.git_name }}" git config user.email "${{ steps.get_user.outputs.git_email }}" + git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ From 713ec2f7489b3468708314ba7c53ddde2abedd8d Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:47:52 -0700 Subject: [PATCH 23/36] add debug prints --- .github/workflows/ci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b96980709..347df71af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -80,6 +80,8 @@ jobs: cd docs + git remote -v + # Setup the committers identity. #git config --global user.email "sdk@temporal.io" #git config --global user.name "Temporal CLI" @@ -90,11 +92,17 @@ jobs: git config user.email "${{ steps.get_user.outputs.git_email }}" git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git + # check token permissions on documentation repo + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ + https://api.github.com/repos/temporalio/documentation | jq '.permissions' + git ls-remote https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git + 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 remote -v git push origin "$BRANCH_NAME" gh pr create \ From 81b1445e4840165b632b1d93f8fefb39a4dc9bb4 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:55:07 -0700 Subject: [PATCH 24/36] more debugging --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 347df71af..a8225e5d0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -93,6 +93,8 @@ jobs: git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git # check token permissions on documentation repo + curl -s -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ + https://api.github.com/user | jq . curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ https://api.github.com/repos/temporalio/documentation | jq '.permissions' git ls-remote https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git @@ -103,7 +105,7 @@ jobs: # TODO: mention CLI release version git commit -m "CLI docs update, autogenerated on CLI release $LATEST_TAG, ${{ github.ref_name }}" git remote -v - git push origin "$BRANCH_NAME" + GIT_TRACE=1 git push origin "$BRANCH_NAME" gh pr create \ --body "Autogenerated PR from https://github.com/temporalio/cli" \ From 23ea994aa3bb6355f8582a84e433408be1e7cd15 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 10 Apr 2025 16:57:18 -0700 Subject: [PATCH 25/36] look up permissions for CLI repo, for comparison --- .github/workflows/ci.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a8225e5d0..d464f905f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -94,10 +94,14 @@ jobs: # check token permissions on documentation repo curl -s -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ - https://api.github.com/user | jq . + https://api.github.com/repos/temporalio/documentation | jq . curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ https://api.github.com/repos/temporalio/documentation | jq '.permissions' - git ls-remote https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git + + curl -s -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ + https://api.github.com/repos/temporalio/cli | jq . + curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ + https://api.github.com/repos/temporalio/cli | jq '.permissions' git checkout -b $BRANCH_NAME cp ../cli/temporalcli/docs/*.mdx docs/cli/ From 0d4dfe2d317ca99bfa65d4100d792122543ae5bb Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 15:28:23 -0700 Subject: [PATCH 26/36] switch to triggering a GH action from the Docs repo --- .github/workflows/ci.yaml | 126 +++++++++----------------------------- 1 file changed, 30 insertions(+), 96 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d464f905f..dda3d10fc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,112 +7,46 @@ on: jobs: update: runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - repository-projects: write defaults: run: shell: bash steps: - - 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 repository - uses: actions/checkout@v4 - with: - path: cli - submodules: recursive - persist-credentials: true - token: ${{ steps.generate_token.outputs.token }} - - - name: Checkout docs repo - uses: actions/checkout@v4 - with: - repository: temporalio/documentation - persist-credentials: true - 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: Get user info from GitHub API id: get_user run: | + echo "GitHub actor: ${{ github.actor }}" + # Query the GitHub API for the user's details. curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ https://api.github.com/users/${{ github.actor }} > user.json - - name=$(jq -r .name user.json) - email="${{ github.actor }}@users.noreply.github.com" # fallback - - echo "git_name=$name" >> $GITHUB_OUTPUT - echo "git_email=$email" >> $GITHUB_OUTPUT - - - - name: Publish generated docs to documentation repo - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} - run: | - set -e - set -x - if [ -z "$GH_TOKEN" ]; then - echo "GH_TOKEN is NOT set" - else - echo "GH_TOKEN is set" + # Extract the user's full name if available, default to the username otherwise. + git_name=$(jq -r '.name // empty' user.json) + if [ -z "$git_name" ]; then + git_name="${{ github.actor }}" fi - BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" - # Remove the "/merge" suffix if it exists - BRANCH_NAME=${BRANCH_NAME%/merge} - - cd docs - - git remote -v - - # Setup the committers identity. - #git config --global user.email "sdk@temporal.io" - #git config --global user.name "Temporal CLI" - - echo "${{ steps.get_user.outputs.git_name }}" - echo "${{ steps.get_user.outputs.git_email }}" - git config user.name "${{ steps.get_user.outputs.git_name }}" - git config user.email "${{ steps.get_user.outputs.git_email }}" - git remote set-url origin https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/temporalio/documentation.git + git_email="${{ github.actor }}@users.noreply.github.com" - # check token permissions on documentation repo - curl -s -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ - https://api.github.com/repos/temporalio/documentation | jq . - curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ - https://api.github.com/repos/temporalio/documentation | jq '.permissions' - - curl -s -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ - https://api.github.com/repos/temporalio/cli | jq . - curl -H "Authorization: token ${{ steps.generate_token.outputs.token }}" \ - https://api.github.com/repos/temporalio/cli | jq '.permissions' - - 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 remote -v - GIT_TRACE=1 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" + # Set the outputs for subsequent steps. + echo "git_name=$git_name" >> $GITHUB_OUTPUT + echo "git_email=$git_email" >> $GITHUB_OUTPUT + + - 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 }} + + # TODO: mention CLI release version + - name: Trigger Documentation Workflow + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh workflow run update-cli-docs.yml \ + -R temporalio/documentation \ + -r cli-docs-autoupdate \ # TODO: change this to main once docs side PR lands in main + -f cli_branch="${{ github.ref_name }}" \ + -f commit_author="${{ steps.get_user.outputs.git_name }}" \ + -f commit_author_email="${{ steps.get_user.outputs.git_email }}" \ + -f commit_message="Update CLI docs for release ${{ github.release.tag_name }}" From b1464107f7e9b4319d6a8659290e9fb28233e8f3 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 16:45:32 -0700 Subject: [PATCH 27/36] try --ref, Why is it runing on default branch? --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dda3d10fc..49792c9da 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,7 +45,7 @@ jobs: run: | gh workflow run update-cli-docs.yml \ -R temporalio/documentation \ - -r cli-docs-autoupdate \ # TODO: change this to main once docs side PR lands in main + --ref cli-docs-autoupdate \ # TODO: change this to main once docs side PR lands in main -f cli_branch="${{ github.ref_name }}" \ -f commit_author="${{ steps.get_user.outputs.git_name }}" \ -f commit_author_email="${{ steps.get_user.outputs.git_email }}" \ From 0bc74845506c7dac75d3ed98a4cb2064978760da Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 16:50:10 -0700 Subject: [PATCH 28/36] move comment --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49792c9da..c6c9fdbed 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,13 +39,14 @@ jobs: private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} # TODO: mention CLI release version + # TODO: change this to main once docs side PR lands in main - name: Trigger Documentation Workflow env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} run: | gh workflow run update-cli-docs.yml \ -R temporalio/documentation \ - --ref cli-docs-autoupdate \ # TODO: change this to main once docs side PR lands in main + --ref cli-docs-autoupdate \ -f cli_branch="${{ github.ref_name }}" \ -f commit_author="${{ steps.get_user.outputs.git_name }}" \ -f commit_author_email="${{ steps.get_user.outputs.git_email }}" \ From e01d627d5b48a26e1c108942bbd4328701ca437e Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 17:25:14 -0700 Subject: [PATCH 29/36] better branch name --- .github/workflows/ci.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c6c9fdbed..f83698eb1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,8 +28,11 @@ jobs: git_email="${{ github.actor }}@users.noreply.github.com" # Set the outputs for subsequent steps. - echo "git_name=$git_name" >> $GITHUB_OUTPUT - echo "git_email=$git_email" >> $GITHUB_OUTPUT + echo "GIT_NAME=$git_name" >> $GITHUB_OUTPUT + echo "GIT_EMAIL=$git_email" >> $GITHUB_OUTPUT + + BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" + echo "BRANCH_NAME=${BRANCH_NAME%/merge}" >> $GITHUB_OUTPUT - name: Generate token id: generate_token @@ -46,8 +49,8 @@ jobs: run: | gh workflow run update-cli-docs.yml \ -R temporalio/documentation \ - --ref cli-docs-autoupdate \ - -f cli_branch="${{ github.ref_name }}" \ - -f commit_author="${{ steps.get_user.outputs.git_name }}" \ - -f commit_author_email="${{ steps.get_user.outputs.git_email }}" \ + -r cli-docs-autoupdate \ + -f cli_branch="${{ steps.get_user.outputs.BRANCH_NAME }}" \ + -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ + -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ -f commit_message="Update CLI docs for release ${{ github.release.tag_name }}" From 51264e5cd23e2bf7af3a95533482155667a67569 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 17:27:31 -0700 Subject: [PATCH 30/36] fix permissions --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f83698eb1..3a61a0cde 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,6 +40,8 @@ jobs: with: app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: documentation # generate a token with permissions to trigger GHA in documentation repo # TODO: mention CLI release version # TODO: change this to main once docs side PR lands in main From 172e7c3b8cf861f77a1de1c6e4e5df8222581c15 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 11 Apr 2025 17:51:44 -0700 Subject: [PATCH 31/36] Fix commit message/branch name --- .github/workflows/ci.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3a61a0cde..e7a79e4b5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,7 +43,6 @@ jobs: owner: ${{ github.repository_owner }} repositories: documentation # generate a token with permissions to trigger GHA in documentation repo - # TODO: mention CLI release version # TODO: change this to main once docs side PR lands in main - name: Trigger Documentation Workflow env: @@ -55,4 +54,4 @@ jobs: -f cli_branch="${{ steps.get_user.outputs.BRANCH_NAME }}" \ -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ - -f commit_message="Update CLI docs for release ${{ github.release.tag_name }}" + -f commit_message="Update CLI docs for release ${{ github.ref_name }}" From 345c7fa9490fd9e50d9ca5784756e2ef16f2d82b Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 14 Apr 2025 08:07:18 -0700 Subject: [PATCH 32/36] use cli_release_tag --- .github/workflows/ci.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e7a79e4b5..5186d30ea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,9 +30,6 @@ jobs: # Set the outputs for subsequent steps. echo "GIT_NAME=$git_name" >> $GITHUB_OUTPUT echo "GIT_EMAIL=$git_email" >> $GITHUB_OUTPUT - - BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" - echo "BRANCH_NAME=${BRANCH_NAME%/merge}" >> $GITHUB_OUTPUT - name: Generate token id: generate_token @@ -51,7 +48,7 @@ jobs: gh workflow run update-cli-docs.yml \ -R temporalio/documentation \ -r cli-docs-autoupdate \ - -f cli_branch="${{ steps.get_user.outputs.BRANCH_NAME }}" \ + -f cli_release_tag="${{ github.ref_name }}" \ -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ -f commit_message="Update CLI docs for release ${{ github.ref_name }}" From ca018399ae961b26d550446fffe03facaa6f19f4 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 14 Apr 2025 08:12:21 -0700 Subject: [PATCH 33/36] use hard coded release tag for testing --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5186d30ea..e3bbcaf79 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,7 +40,7 @@ jobs: owner: ${{ github.repository_owner }} repositories: documentation # generate a token with permissions to trigger GHA in documentation repo - # TODO: change this to main once docs side PR lands in main + # TODO: change this to cli_release_tag="${{ github.ref_name }}" \ before merging these changes - name: Trigger Documentation Workflow env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} @@ -48,7 +48,7 @@ jobs: gh workflow run update-cli-docs.yml \ -R temporalio/documentation \ -r cli-docs-autoupdate \ - -f cli_release_tag="${{ github.ref_name }}" \ + -f cli_release_tag="v1.3.0" \ -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ -f commit_message="Update CLI docs for release ${{ github.ref_name }}" From e64a69fa8cc46cb11bece582e2e04df2984adbae Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 29 Apr 2025 12:27:23 -0700 Subject: [PATCH 34/36] misc doc fix --- temporalcli/commandsgen/commands.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/temporalcli/commandsgen/commands.yml b/temporalcli/commandsgen/commands.yml index 2e94dad79..ba67fdf9a 100644 --- a/temporalcli/commandsgen/commands.yml +++ b/temporalcli/commandsgen/commands.yml @@ -395,8 +395,6 @@ commands: One of those parameters must be provided. If both are provided - Activity Type will be used, and Activity ID will be ignored. - ``` - Specify the Activity and Workflow IDs: ``` From 53123e4eef8cb564143ea72a3dcfe2a1634e42a8 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 29 Apr 2025 12:33:20 -0700 Subject: [PATCH 35/36] Create new trigger-docs action, change ci back to original code --- .github/workflows/ci.yaml | 125 ++++++++++++++++++----------- .github/workflows/trigger-docs.yml | 52 ++++++++++++ 2 files changed, 132 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/trigger-docs.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3bbcaf79..1e054a3ec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,54 +1,89 @@ name: Continuous Integration on: pull_request: - workflow_dispatch: - release: - types: [published] + push: + branches: + - main + jobs: - update: - runs-on: ubuntu-latest - defaults: - run: - shell: bash + build-test: + strategy: + fail-fast: false + 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: Get user info from GitHub API - id: get_user - run: | - echo "GitHub actor: ${{ github.actor }}" - # Query the GitHub API for the user's details. - curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/users/${{ github.actor }} > user.json - - # Extract the user's full name if available, default to the username otherwise. - git_name=$(jq -r '.name // empty' user.json) - if [ -z "$git_name" ]; then - git_name="${{ github.actor }}" - fi - - git_email="${{ github.actor }}@users.noreply.github.com" - - # Set the outputs for subsequent steps. - echo "GIT_NAME=$git_name" >> $GITHUB_OUTPUT - echo "GIT_EMAIL=$git_email" >> $GITHUB_OUTPUT - - - name: Generate token - id: generate_token - uses: actions/create-github-app-token@v1 + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Install gotestsum + run: go install gotest.tools/gotestsum@latest + + - name: Create junit-xml directory + run: mkdir junit-xml + + - name: Test + run: gotestsum --junitfile junit-xml/${{matrix.os}}.xml -- ./... + + - name: 'Upload junit-xml artifacts' + uses: actions/upload-artifact@v4 + if: always() with: - app-id: ${{ secrets.TEMPORAL_CICD_APP_ID }} - private-key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: documentation # generate a token with permissions to trigger GHA in documentation repo + name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{matrix.os}} + path: junit-xml + retention-days: 14 - # TODO: change this to cli_release_tag="${{ github.ref_name }}" \ before merging these changes - - name: Trigger Documentation Workflow + - name: Regen code, confirm unchanged + if: ${{ matrix.checkGenCodeTarget }} + run: | + go run ./temporalcli/internal/cmd/gen-commands + git diff --exit-code + + - name: Test cloud mTLS + if: ${{ matrix.cloudTestTarget && env.HAS_SECRETS == 'true' }} env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + 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: | - gh workflow run update-cli-docs.yml \ - -R temporalio/documentation \ - -r cli-docs-autoupdate \ - -f cli_release_tag="v1.3.0" \ - -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ - -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ - -f commit_message="Update CLI docs for release ${{ github.ref_name }}" + printf '%s\n' "$TEMPORAL_TLS_CERT_CONTENT" >> client.crt + printf '%s\n' "$TEMPORAL_TLS_KEY_CONTENT" >> client.key + go run ./cmd/temporal workflow list --limit 2 + + - name: Test cloud API key env var + if: ${{ matrix.cloudTestTarget && env.HAS_SECRETS == 'true' }} + env: + TEMPORAL_ADDRESS: us-west-2.aws.api.temporal.io:7233 + TEMPORAL_NAMESPACE: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }} + TEMPORAL_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }} + shell: bash + run: go run ./cmd/temporal workflow list --limit 2 + + - name: Test cloud API key arg + if: ${{ matrix.cloudTestTarget && env.HAS_SECRETS == 'true' }} + env: + TEMPORAL_ADDRESS: us-west-2.aws.api.temporal.io:7233 + TEMPORAL_NAMESPACE: ${{ vars.TEMPORAL_CLIENT_NAMESPACE }} + shell: bash + run: go run ./cmd/temporal workflow list --limit 2 --api-key ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }} \ No newline at end of file diff --git a/.github/workflows/trigger-docs.yml b/.github/workflows/trigger-docs.yml new file mode 100644 index 000000000..1fda1f26b --- /dev/null +++ b/.github/workflows/trigger-docs.yml @@ -0,0 +1,52 @@ +name: Continuous Integration +on: + workflow_dispatch: + release: + types: [published] +jobs: + update: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Get user info from GitHub API + id: get_user + run: | + echo "GitHub actor: ${{ github.actor }}" + # Query the GitHub API for the user's details. + curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/users/${{ github.actor }} > user.json + + # Extract the user's full name if available, default to the username otherwise. + git_name=$(jq -r '.name // empty' user.json) + if [ -z "$git_name" ]; then + git_name="${{ github.actor }}" + fi + + git_email="${{ github.actor }}@users.noreply.github.com" + + # Set the outputs for subsequent steps. + echo "GIT_NAME=$git_name" >> $GITHUB_OUTPUT + echo "GIT_EMAIL=$git_email" >> $GITHUB_OUTPUT + + - 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 }} + owner: ${{ github.repository_owner }} + repositories: documentation # generate a token with permissions to trigger GHA in documentation repo + + - name: Trigger Documentation Workflow + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + gh workflow run update-cli-docs.yml \ + -R temporalio/documentation \ + -r cli-docs-autoupdate \ + -f cli_release_tag="${{ github.ref_name }}" \ + -f commit_author="${{ steps.get_user.outputs.GIT_NAME }}" \ + -f commit_author_email="${{ steps.get_user.outputs.GIT_EMAIL }}" \ + -f commit_message="Update CLI docs for release ${{ github.ref_name }}" From 0b2cc5500da69de4aa11646c64785581309adfce Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Tue, 29 Apr 2025 12:43:00 -0700 Subject: [PATCH 36/36] regen commands.gen.go --- temporalcli/commands.gen.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index ace142da3..a171230e1 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -473,9 +473,9 @@ func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActiv s.Command.Use = "pause [flags]" s.Command.Short = "Pause an Activity" if hasHighlighting { - s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run to completion.\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities can be specified by their Activity ID or Activity Type. \nOne of those parameters must be provided. If both are provided - Activity\nType will be used, and Activity ID will be ignored.\n\n\x1b[1mSpecify the Activity and Workflow IDs:\x1b[0m\ntemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```" + s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run to completion.\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities can be specified by their Activity ID or Activity Type. \nOne of those parameters must be provided. If both are provided - Activity\nType will be used, and Activity ID will be ignored.\n\nSpecify the Activity and Workflow IDs:\n\n\x1b[1mtemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\x1b[0m" } else { - s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run to completion.\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities can be specified by their Activity ID or Activity Type. \nOne of those parameters must be provided. If both are provided - Activity\nType will be used, and Activity ID will be ignored.\n\n```\n\nSpecify the Activity and Workflow IDs:\n\n```\ntemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```" + s.Command.Long = "Pause an Activity.\n\nIf the Activity is not currently running (e.g. because it previously\nfailed), it will not be run again until it is unpaused.\n\nHowever, if the Activity is currently running, it will run to completion.\nIf the Activity is on its last retry attempt and fails, the failure will\nbe returned to the caller, just as if the Activity had not been paused.\n\nActivities can be specified by their Activity ID or Activity Type. \nOne of those parameters must be provided. If both are provided - Activity\nType will be used, and Activity ID will be ignored.\n\nSpecify the Activity and Workflow IDs:\n\n```\ntemporal activity pause \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n```" } s.Command.Args = cobra.NoArgs s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "Activity ID to pause.")