diff --git a/.github/actions-scripts/purge-fastly-edge-cache.js b/.github/actions-scripts/purge-fastly-edge-cache.js index 30869ee94f60..0c6a5f3931d7 100755 --- a/.github/actions-scripts/purge-fastly-edge-cache.js +++ b/.github/actions-scripts/purge-fastly-edge-cache.js @@ -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) diff --git a/.github/workflows/sync-search-elasticsearch.yml b/.github/workflows/sync-search-elasticsearch.yml index 0a88c08f2b09..7980a2a35c94 100644 --- a/.github/workflows/sync-search-elasticsearch.yml +++ b/.github/workflows/sync-search-elasticsearch.yml @@ -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: diff --git a/script/deployment/purge-edge-cache.js b/script/deployment/purge-edge-cache.js index 8cdc8852b4fa..47d073230a3d 100644 --- a/script/deployment/purge-edge-cache.js +++ b/script/deployment/purge-edge-cache.js @@ -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) {