Debian Codegraph @

.github/workflows/main.yml

raw
1 # Copyright 2021 Google LLC
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6
7 # https://www.apache.org/licenses/LICENSE-2.0
8
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 name: A workflow for updating discovery artifacts
16 # Controls when the action will run.
17
18 on:
19 schedule:
20 # * is a special character in YAML so you have to quote this string
21 # Run this Github Action every Tuesday at 7 AM UTC
22 - cron: '0 7 * * 2'
23 workflow_dispatch:
24
25 jobs:
26 build:
27 name: Update Discovery Artifacts PR
28 runs-on: ubuntu-latest
29 if: ${{github.repository == 'googleapis/google-api-python-client'}}
30 steps:
31 - name: Get current date
32 id: date
33 run: echo "::set-output name=current_date::$(date +'%Y-%m-%d-%HH%MM%SS')"
34
35 - name: Sync fork
36 run: gh repo sync $REPOSITORY -b $BRANCH_NAME
37 env:
38 REPOSITORY: 'yoshi-code-bot/google-api-python-client'
39 BRANCH_NAME: 'refs/heads/main'
40 GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
41
42 - name: Check out main branch
43 uses: actions/checkout@v4
44 with:
45 ref: refs/heads/main
46 repository: 'yoshi-code-bot/google-api-python-client'
47 token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
48
49 - name: Create branch
50 run: |
51 git checkout -b update-discovery-artifacts-${{ steps.date.outputs.current_date }}
52
53 - name: Set up Python 3.9
54 uses: actions/setup-python@v5
55 with:
56 python-version: 3.9
57
58 - name: Install google-api-python-client
59 run: pip3 install -e .
60
61 - name: Install script dependencies
62 run: pip3 install -r requirements.txt
63 working-directory: ./scripts
64
65 # Apply a workaround to discovery.py to avoid DefaultCredentialsError
66 # which is raised when calling `build_from_document()` as a result of
67 # `google.auth.default()`. The workaround is to bypass the code block that
68 # attempts to load default credentials.
69 - name: Workaround to avoid DefaultCredentialsError in discovery.py
70 run: sed -i -e 's/if credentials is None/if False/g' googleapiclient/discovery.py
71
72 - name: Run Change Summary
73 run: python3 updatediscoveryartifacts.py
74 working-directory: ./scripts
75
76 - name: Commit changes
77 run: ./createcommits.sh
78 working-directory: ./scripts
79
80 - name: Push changes
81 run: git push -u origin update-discovery-artifacts-${{ steps.date.outputs.current_date }}
82
83 - name: Prepare summary for PR Body
84 id: pr_body
85 shell: bash
86 run: |
87 python3 buildprbody.py
88 output=$(cat temp/allapis.summary)
89 output="${output//'%'/'%25'}"
90 output="${output//$'\n'/'%0A'}"
91 output="${output//$'\r'/'%0D'}"
92 echo "::set-output name=change_summary::$output"
93 working-directory: ./scripts
94
95 - name: Create PR
96 env:
97 GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
98 PR_TITLE: "chore: Update discovery artifacts"
99 run: |
100 gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${{ steps.pr_body.outputs.change_summary }}"