Skip to content

repo sync #22529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/actions-scripts/purge-fastly-edge-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
20 changes: 20 additions & 0 deletions .github/workflows/sync-search-elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions script/deployment/purge-edge-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@ 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 = {
'fastly-key': apiToken,
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) {
Expand Down