0

I am trying to build a docker image and pushing it to gcp artifactory. But it is failing in the github actions. Here is my workflow yaml file:

on:
  push:
    branches:
    - main
    - featurev1

name: Build and Deploy to Cloud Run
env:
  REGION: 'europe-west1'
  PROJECT_ID: 'myproject'
  CLUSTER_NAME: 'myproject-cluster'
  LOCATION: 'europe-west1'
  ZONE: 'europe-west1'
  ARTIFACT_REGISTRY: 'myproject-cust-seg'
  TARGET_ENV: 'INT'
  NAMESPACE: 'integration'

jobs:
  deploy:
    runs-on:  [ self-hosted ]

    # Add "id-token" with the intended permissions.
    #permissions:
    #  contents: 'read'
    #  id-token: 'write'

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup gcloud environment
      uses: google-github-actions/setup-gcloud@v0
      with:       
        service_account_key: ${{ secrets.INT_PLATFORM_SERVICE_ACCOUNT_KEY }}
        project_id: ${{ env.PROJECT_ID }}

    
    # Alternative option - authentication via credentials json
    #- id: 'auth'
    #  uses: 'google-github-actions/auth@v0'
    #  with:
    #     credentials_json: ${{ secrets.INT_PLATFORM_SERVICE_ACCOUNT_KEY }}

    
    - name: Authorize Docker push
      run: gcloud auth configure-docker

    - name: Build and Push Container
      env:
        GIT_TAG: ${{ github.run_id }}
      run: |-
        docker build -t $LOCATION-docker.pkg.dev/$PROJECT_ID/$ARTIFACT_REGISTRY/custapi:$TARGET_ENV-v$GIT_TAG .
        docker push $LOCATION-docker.pkg.dev/$PROJECT_ID/$ARTIFACT_REGISTRY/custapi:$TARGET_ENV-v$GIT_TAG

But I have an error:

Run google-github-actions/setup-gcloud@v0 Error: google-github-actions/setup-gcloud failed with: failed to execute command gcloud --quiet config set project myproject: WARNING: Could not setup log file in /home/master/.config/gcloud/logs, (Could not create directory [/home/master/.config/gcloud/logs/2022.02.10]: Permission denied. Please verify that you have permissions to write to the parent directory.. The configuration directory may not be writable. To learn more, see https://cloud.google.com/sdk/docs/configurations#creating_a_configuration ERROR: (gcloud.config.set) Failed to create the default configuration. Ensure your have the correct permissions on: [/home/master/.config/gcloud/configurations]. Could not create directory [/home/master/.config/gcloud/configurations]: Permission denied. Please verify that you have permission to write to the parent directory.

Right now I have used the service key json file as secret in GitHub actions as keyless authentication will be done in the near future, after the successful pilot of phase 1. So you could find the details above.

Here I have mentioned runs-on as "self-hosted" which is our onpremise github action runner.

ARINDAM BANERJEE
  • 659
  • 1
  • 8
  • 29
  • It appears the user does not have sufficient permissions to run any gcloud commands. Can you please confirm that? What permissions are set to the path `/home/master/.config/gcloud` and if the user running the jobs have permissions to write to the path. – CaioT Feb 10 '22 at 14:19
  • yes it seems so. but i don't have the rights to see as it is owned by other team in my client's side. – ARINDAM BANERJEE Feb 10 '22 at 15:24

0 Answers0