1
0
mirror of synced 2026-01-05 21:04:17 -05:00

Merge pull request #22529 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2022-12-07 12:01:53 -08:00
committed by GitHub
3 changed files with 26 additions and 7 deletions

View File

@@ -2,7 +2,8 @@
import { SURROGATE_ENUMS } from '../../middleware/set-fastly-surrogate-key.js'
import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js'
// This will purge every response that *contains* `SURROGATE_ENUMS.DEFAULT`.
// This will purge every response that *contains*
// `process.env.FASTLY_SURROGATE_KEY || SURROGATE_ENUMS.DEFAULT`.
// We normally send Surrogate-Key values like:
//
// every-deployment language:en
@@ -17,4 +18,4 @@ import purgeEdgeCache from '../../script/deployment/purge-edge-cache.js'
//
// It will cover all surrogate keys that contain that.
// So this the nuclear option for all keys with this prefix.
await purgeEdgeCache(SURROGATE_ENUMS.DEFAULT)
await purgeEdgeCache(process.env.FASTLY_SURROGATE_KEY || SURROGATE_ENUMS.DEFAULT)

View File

@@ -35,6 +35,18 @@ env:
FREEZE: ${{ secrets.FREEZE }}
ELASTICSEARCH_URL: ${{ secrets.ELASTICSEARCH_URL }}
# This might seem a bit strange, but it's clever. Since this action
# uses a matrix to deal with one language at a time, we can use this
# to pretend it's always the same directory.
TRANSLATIONS_ROOT_ES_ES: translation
TRANSLATIONS_ROOT_ZH_CN: translation
TRANSLATIONS_ROOT_JA_JP: translation
TRANSLATIONS_ROOT_PT_BR: translation
TRANSLATIONS_ROOT_FR_FR: translation
TRANSLATIONS_ROOT_RU_RU: translation
TRANSLATIONS_ROOT_KO_KR: translation
TRANSLATIONS_ROOT_DE_DE: translation
jobs:
figureOutMatrix:
runs-on: ubuntu-latest
@@ -98,6 +110,14 @@ jobs:
- name: Check out repo
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
- name: Checkout the non-English repo
if: ${{ matrix.language != 'en' }}
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
with:
repository: github/docs-internal.${{ fromJSON('{"cn":"zh-cn","es":"es-es","ru":"ru-ru","ja":"ja-jp","pt":"pt-br","de":"de-de","fr":"fr-fr","ko":"ko-kr"}')[matrix.language] }}
token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
path: translation
- name: Setup Node
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
with:

View File

@@ -16,7 +16,6 @@ const DELAY_BEFORE_SECOND_PURGE = 30 * 1000
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
async function purgeFastlyBySurrogateKey({ apiToken, serviceId, surrogateKey }) {
const key = surrogateKey
const safeServiceId = encodeURIComponent(serviceId)
const headers = {
@@ -24,23 +23,22 @@ async function purgeFastlyBySurrogateKey({ apiToken, serviceId, surrogateKey })
accept: 'application/json',
'fastly-soft-purge': '1',
}
const requestPath = `https://api.fastly.com/service/${safeServiceId}/purge/${key}`
const requestPath = `https://api.fastly.com/service/${safeServiceId}/purge/${surrogateKey}`
return got.post(requestPath, { headers, json: true })
}
export default async function purgeEdgeCache(
key,
surrogateKey,
{
purgeTwice = true,
delayBeforeFirstPurge = DELAY_BEFORE_FIRST_PURGE,
delayBeforeSecondPurge = DELAY_BEFORE_SECOND_PURGE,
} = {}
) {
const surrogateKey = key || process.env.FASTLY_SURROGATE_KEY
if (!surrogateKey) {
throw new Error('No key set and/or no FASTLY_SURROGATE_KEY env var set')
}
console.log(`Fastly purgeEdgeCache initialized for ${surrogateKey}...`)
console.log(`Fastly purgeEdgeCache initialized for: '${surrogateKey}'`)
const { FASTLY_TOKEN, FASTLY_SERVICE_ID } = process.env
if (!FASTLY_TOKEN || !FASTLY_SERVICE_ID) {