| name: 'Authenticate for GCP' |
| description: 'Authenticate a workflow for Protobuf CI testing' |
| inputs: |
| credentials: |
| required: true |
| description: "The GCP credentials to use for GCP" |
| type: string |
| |
| outputs: |
| credentials-file: |
| description: "Credentials file generated for GCP" |
| value: ${{ steps.output.outputs.credentials-file }} |
| |
| runs: |
| using: 'composite' |
| steps: |
| - name: Authenticate to Google Cloud |
| id: auth |
| uses: google-github-actions/auth@ef5d53e30bbcd8d0836f4288f5e50ff3e086997d # v1.0.0 |
| with: |
| credentials_json: ${{ inputs.credentials }} |
| - name: Set up Cloud SDK |
| uses: google-github-actions/setup-gcloud@d51b5346f85640ec2aa2fa057354d2b82c2fcbce # v1.0.1 |
| - name: Use gcloud CLI |
| shell: bash |
| run: gcloud info |
| |
| - name: Store credentials path |
| shell: bash |
| run: echo "CREDENTIALS_FILE=${{ steps.auth.outputs.credentials_file_path }}" >> $GITHUB_ENV |
| |
| - name: Fix credentials path (Windows) |
| if: ${{ runner.os == 'Windows' }} |
| # Bash commands in windows don't like the backslash in the file path. |
| # Assume we're running in the root directory and grab the base name. |
| shell: bash |
| run: echo "CREDENTIALS_FILE="$(basename ${CREDENTIALS_FILE//\\//}) >> $GITHUB_ENV |
| |
| - name: Output credentials file |
| id: output |
| shell: bash |
| run: echo "credentials-file=${{ env.CREDENTIALS_FILE }}" >> $GITHUB_OUTPUT |