diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dec27bbdf..0e4d5af77 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,72 +1,121 @@ 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 + +# 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@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 +# - 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: | - 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" diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 000000000..77e834cf7 --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,51 @@ +name: Update Documentation repository +on: + workflow_dispatch: + release: + types: [published] +jobs: + update: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + path: cli + + - name: Checkout Documentation repo + uses: actions/checkout@v4 + with: + repository: temporalio/documentation + path: docs + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + + - name: Generate CLI docs + run: | + echo "$pwd" + go run ./temporalcli/internal/cmd/gen-docs + + - name: Copy files over and generate PR + run: | + BRANCH_NAME="cli-update-docs-${{ github.ref_name }}" + + cd docs + git checkout -b $BRANCH_NAME + cp ../cli/temporalcli/docs/*.mdx docs/cli/ + git add . + git commit -m "CLI docs update, autogenerated on CLI release, ${{ 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"