From b9cc6d9574586b9ac0848b9cd5d3d4eb04e6913d Mon Sep 17 00:00:00 2001 From: ace-n Date: Fri, 11 Nov 2022 15:58:40 -0800 Subject: [PATCH] Add workflows --- .github/workflows/document-ai.yaml | 68 ++++++++++++++++++++++++++++++ .github/workflows/workflows.json | 1 + 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/document-ai.yaml diff --git a/.github/workflows/document-ai.yaml b/.github/workflows/document-ai.yaml new file mode 100644 index 0000000000..0cbc4b6000 --- /dev/null +++ b/.github/workflows/document-ai.yaml @@ -0,0 +1,68 @@ +name: document-ai +on: + push: + branches: + - main + paths: + - 'document-ai/**' + pull_request: + paths: + - 'document-ai/**' + pull_request_target: + types: [labeled] + paths: + - 'document-ai/**' + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: actions/checkout@v3.1.0 + with: + ref: ${{github.event.pull_request.head.sha}} + - uses: 'google-github-actions/auth@v1.0.0' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/setup-node@v3.5.1 + with: + node-version: 16 + - run: npm install + working-directory: document-ai + - run: npm test + working-directory: document-ai + env: + MOCHA_REPORTER_SUITENAME: document-ai + MOCHA_REPORTER_OUTPUT: document_ai_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/workflows.json b/.github/workflows/workflows.json index 13773a413a..919d5a5cb3 100644 --- a/.github/workflows/workflows.json +++ b/.github/workflows/workflows.json @@ -29,6 +29,7 @@ "datalabeling", "datastore/functions", "datacatalog/quickstart", + "document-ai", "endpoints/getting-started", "endpoints/getting-started-grpc", "error-reporting",