Skip to content

Commit

Permalink
Use the trigger-publish pipeline to test new pipeline changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yuandrew committed Dec 6, 2024
1 parent bd65701 commit d9bf7f9
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 54 deletions.
88 changes: 54 additions & 34 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,69 @@
name: Continuous Integration
on:
workflow_dispatch:
release:
types: [published]
jobs:
update:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
pull_request:
push:
branches:
- main

jobs:
build-test:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, macos-14, 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 }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
path: cli

- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: temporalio/documentation
path: docs
submodules: recursive

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Generate CLI docs
run: go run ./cli/temporalcli/internal/cmd/gen-docs
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest

- name: Create junit-xml directory
run: mkdir junit-xml

- name: Copy files over and generate PR
- name: Test
run: gotestsum --junitfile junit-xml/${{matrix.os}}.xml -- ./...

- name: 'Upload junit-xml artifacts'
uses: actions/upload-artifact@v4
if: always()
with:
name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{matrix.os}}
path: junit-xml
retention-days: 14

- name: Regen code, confirm unchanged
if: ${{ matrix.checkGenCodeTarget }}
run: |
go run ./temporalcli/internal/cmd/gen-commands
git diff --exit-code
- name: Test cloud
# Only supported in non-fork runs, since secrets are not available in forks
if: ${{ matrix.cloudTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/cli') }}
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: |
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"
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
53 changes: 33 additions & 20 deletions .github/workflows/trigger-publish.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
name: 'Trigger Docker image build'

on:
workflow_dispatch:
release:
types: [published]

jobs:
trigger:
if: ${{ ! contains(github.ref, '-rc.') }}
name: 'trigger Docker image build'
update:
runs-on: ubuntu-latest

defaults:
run:
shell: bash

steps:
- name: Generate a token
id: generate_token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
- name: Checkout repository
uses: actions/checkout@v2
with:
path: cli

- name: Checkout tools repo
uses: actions/checkout@v4
with:
app_id: ${{ secrets.TEMPORAL_CICD_APP_ID }}
private_key: ${{ secrets.TEMPORAL_CICD_PRIVATE_KEY }}
repository: temporalio/documentation
path: docs

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: Generate CLI docs
run: go run ./cli/temporalcli/internal/cmd/gen-docs

- name: Dispatch docker builds Github Action
env:
PAT: ${{ steps.generate_token.outputs.token }}
PARENT_REPO: temporalio/docker-builds
PARENT_BRANCH: ${{ toJSON('main') }}
WORKFLOW_ID: update-submodules.yml
REPO: ${{ toJSON('cli') }}
BRANCH: ${{ toJSON('main') }}
COMMIT: ${{ toJSON(github.sha) }}
- name: Copy files over and generate PR
run: |
curl -fL -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $PAT" "https://api.github.com/repos/$PARENT_REPO/actions/workflows/$WORKFLOW_ID/dispatches" -d '{"ref":'"$PARENT_BRANCH"', "inputs": { "repo":'"$REPO"', "branch":'"$BRANCH"', "commit": '"$COMMIT"' }}'
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"

0 comments on commit d9bf7f9

Please sign in to comment.