mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 05:00:10 +00:00
Add GitHub Actions workflow for staged rollout of Chrome extension
This commit is contained in:
68
.github/workflows/staged-rollout-browser.yml
vendored
Normal file
68
.github/workflows/staged-rollout-browser.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Staged Rollout Browser Chrome
|
||||
run-name: Staged Rollout Browser Chrome - ${{ inputs.rollout_percentage }}%
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
rollout_percentage:
|
||||
description: 'Staged Rollout Percentage'
|
||||
required: true
|
||||
default: '10'
|
||||
type: string
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
rollout:
|
||||
name: Update Chrome Rollout Percentage
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Login to Azure
|
||||
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
|
||||
with:
|
||||
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
||||
|
||||
- name: Retrieve secrets
|
||||
id: retrieve-secrets
|
||||
uses: bitwarden/gh-actions/get-keyvault-secrets@main
|
||||
with:
|
||||
keyvault: "bitwarden-ci"
|
||||
secrets: "CHROME_CLIENT_ID,CHROME_CLIENT_SECRET,CHROME_REFRESH_TOKEN,CHROME_EXTENSION_ID"
|
||||
|
||||
- name: Get OAuth token
|
||||
id: auth
|
||||
env:
|
||||
CHROME_CLIENT_ID: ${{ steps.retrieve-secrets.outputs.CHROME_CLIENT_ID }}
|
||||
CHROME_CLIENT_SECRET: ${{ steps.retrieve-secrets.outputs.CHROME_CLIENT_SECRET }}
|
||||
CHROME_REFRESH_TOKEN: ${{ steps.retrieve-secrets.outputs.CHROME_REFRESH_TOKEN }}
|
||||
run: |
|
||||
ACCESS_TOKEN=$(curl -s -X POST \
|
||||
"https://oauth2.googleapis.com/token" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-d "client_id=$CHROME_CLIENT_ID" \
|
||||
-d "client_secret=$CHROME_CLIENT_SECRET" \
|
||||
-d "refresh_token=$CHROME_REFRESH_TOKEN" \
|
||||
-d "grant_type=refresh_token" | \
|
||||
jq -r '.access_token')
|
||||
|
||||
echo "access_token=$ACCESS_TOKEN" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set staged rollout percentage
|
||||
env:
|
||||
ROLLOUT_PCT: ${{ inputs.rollout_percentage }}
|
||||
ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
|
||||
CHROME_EXTENSION_ID: ${{ steps.retrieve-secrets.outputs.CHROME_EXTENSION_ID }}
|
||||
run: |
|
||||
if [[ ! $ROLLOUT_PCT =~ ^[0-9]+$ ]] || [ "$ROLLOUT_PCT" -lt 0 ] || [ "$ROLLOUT_PCT" -gt 100 ]; then
|
||||
echo "Error: Rollout percentage must be an integer between 0 and 100."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -s -X POST \
|
||||
"https://www.googleapis.com/chromewebstore/v1.1/items/${CHROME_EXTENSION_ID}/stagedRollout" \
|
||||
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"rolloutPercentage\": $ROLLOUT_PCT}"
|
||||
|
||||
Reference in New Issue
Block a user