Skip to content

ci: update Python runtime to 3.14 in GHA workflow #532

ci: update Python runtime to 3.14 in GHA workflow

ci: update Python runtime to 3.14 in GHA workflow #532

Workflow file for this run

# Copyright 2021 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: A workflow for updating discovery artifacts
# Controls when the action will run.
on:
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string
# Run this Github Action every Tuesday at 7 AM UTC
- cron: '0 7 * * 2'
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Update Discovery Artifacts PR
runs-on: ubuntu-latest
if: ${{github.repository == 'googleapis/google-api-python-client'}}
steps:
- name: Get current date
id: date
run: echo "::set-output name=current_date::$(date +'%Y-%m-%d-%HH%MM%SS')"
- name: Sync fork
run: gh repo sync $REPOSITORY -b $BRANCH_NAME
env:
REPOSITORY: 'yoshi-code-bot/google-api-python-client'
BRANCH_NAME: 'refs/heads/main'
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
- name: Check out main branch
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: refs/heads/main
repository: 'yoshi-code-bot/google-api-python-client'
token: ${{secrets.YOSHI_CODE_BOT_TOKEN}}
persist-credentials: false
fetch-depth: 0
- name: Create branch
run: |
git checkout -b update-discovery-artifacts-${STEPS_DATE_OUTPUTS_CURRENT_DATE}
env:
STEPS_DATE_OUTPUTS_CURRENT_DATE: ${{ steps.date.outputs.current_date }}
- name: Set up Python 3.14
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: 3.14
- name: Install google-api-python-client
run: pip3 install -e .
# Checkout requirements.txt from the PR branch on the main repository
- name: Checkout requirements.txt from PR branch
if: github.event_name == 'pull_request'
run: |
git fetch https://github.com/googleapis/google-api-python-client.git refs/pull/${{ github.event.pull_request.number }}/head:pr-branch
git checkout pr-branch -- scripts/requirements.txt
- name: Install script dependencies
run: pip3 install -r requirements.txt
working-directory: ./scripts
# Apply a workaround to discovery.py to avoid DefaultCredentialsError
# which is raised when calling `build_from_document()` as a result of
# `google.auth.default()`. The workaround is to bypass the code block that
# attempts to load default credentials.
- name: Workaround to avoid DefaultCredentialsError in discovery.py
run: sed -i -e 's/if credentials is None/if False/g' googleapiclient/discovery.py
- name: Run Change Summary
run: python3 updatediscoveryartifacts.py
working-directory: ./scripts
- name: Commit changes
run: ./createcommits.sh
working-directory: ./scripts
- name: Push changes
run: git push -u origin update-discovery-artifacts-${STEPS_DATE_OUTPUTS_CURRENT_DATE}
env:
STEPS_DATE_OUTPUTS_CURRENT_DATE: ${{ steps.date.outputs.current_date }}
- name: Prepare summary for PR Body
id: pr_body
shell: bash
run: |
python3 buildprbody.py
output=$(cat temp/allapis.summary)
output="${output//'%'/'%25'}"
output="${output//$'\n'/'%0A'}"
output="${output//$'\r'/'%0D'}"
echo "::set-output name=change_summary::$output"
working-directory: ./scripts
- name: Create PR
env:
GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
PR_TITLE: "chore: Update discovery artifacts"
STEPS_PR_BODY_OUTPUTS_CHANGE_SUMMARY: ${{ steps.pr_body.outputs.change_summary }}
run: |
gh pr create -R "googleapis/google-api-python-client" -B "main" --title "$PR_TITLE" --body "${STEPS_PR_BODY_OUTPUTS_CHANGE_SUMMARY}"