Github actions to google cloud run takes about 7 mins. Is that normal?
google cloud platform - Github Actions Failing for setup-gcloud - Stack Overflow
Setting up gcloud takes more than a minute on GitHub Runners
documentation misleading for Application Default Credentials
Videos
Hi everyone, am new to ci/cd and am trying to automate a deployment of an api (written in nodejs) and deploy it as a Google Cloud Run upon a commit made to GitHub "main" branch.
Currently am using the below script for the requirement and running on GitHub Actions. However it seems to be taking approximately 7 mins in total (3.5 mins to 'setup Google Cloud SDK' & 3.5 min to 'build and push container' ) for the workflow to complete running.
Am wondering if that is normal or is there anyway to reduce the time taken to run it?
jobs: deploy: runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Google Cloud SDK
uses: google-github-actions/setup-gcloud@v0.2.1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Authorize Docker push
run: gcloud auth configure-docker
- name: Build and Push Container
run: |-
gcloud builds submit --gcs-log-dir $BUILD_LOGS_BUCKET --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy $SERVICE_NAME \
--region $REGION \
--image gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} \
--platform managed \
--allow-unauthenticatedI fixed it by using below lines in workflow yml before uses: google-github-actions/setup-gcloud@v0
- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
Answer above did not work for us, however, we're able to identify and fix the the problem by doing followings.
Problem: The python version used in our action was somehow 3.10.3 which is not compliant with gcloud cli.
Official gcloud docs says:
The gcloud CLI runs under Python. Note that gcloud requires Python version 3.5-3.9
Solution: We've updated github workflow definition to setup a supported version of the python by the gcloud cli.
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Export gcloud related env variable
run: export CLOUDSDK_PYTHON="/usr/bin/python3"