Skip to content

Rotate Google Service Account Keys for Github Actions

Notifications You must be signed in to change notification settings

miklosn/github-action-rotate-gcp-key

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-action-rotate-gcp-key

This action rotates GCP service account keys in with the following method:

  1. Create a new key for the SA
  2. Update the specified Github secret (in one or more repos)
  3. Delete all keys which do not equal the newly created key and which are also older than 5 minutes (to prevent race errors)

Example workflow

name: Rotate GCP service account key
#on:
#  schedule:
#    - cron: '0 12 * * 1'
on: [workflow_dispatch]
jobs:
  rotate:
    name: rotate gcp key
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: Setup GCP Service Account
        uses: google-github-actions/setup-gcloud@master
        with:
          service_account_key: ${{ secrets.GCP_SA_INFRA_KEY }}
          export_default_credentials: true
      - name: rotate gcp keys
        uses: miklosn/github-action-rotate-gcp-key@main # WARNING: use explicit Git commit sha instead of 'main' to avoid becoming a victim of supply chain attacks
        with:
          projectId: "example"
          serviceAccount: "[email protected]"
          personalAccessToken: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
          repositories: ${{ github.repository }}
          secretName: "GCP_SA_INFRA_KEY"

Inputs

projectId: GCP project id to operate on

serviceAccount: e-mail ID of the service account to operate on

personalAccessToken: github token with permission to add/update secrets on a repo basis

secretName: name of the Github secret to update

repositories: one or multiple github repos. If multiple repos are specified they need to be separated by commas. The secret will be updated in all repos.

About

Rotate Google Service Account Keys for Github Actions

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •