Merge pull request #35705 from github/repo-sync #5956
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Purge Fastly | |
# **What it does**: Sends a soft-purge to Fastly. | |
# **Why we have it**: So that, right after a production deploy, we start afresh | |
# **Who does it impact**: Writers and engineers. | |
on: | |
workflow_dispatch: | |
inputs: | |
nuke_all: | |
description: "Nuke all 'every-deployment' keys independent of language" | |
required: false | |
type: boolean | |
default: false | |
languages: | |
description: "Comma separated languages. E.g. 'en,ja, es' (defaults to all)" | |
required: false | |
default: '' | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
env: | |
FASTLY_TOKEN: ${{ secrets.FASTLY_TOKEN }} | |
FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }} | |
jobs: | |
send-purges: | |
if: >- | |
${{ | |
github.repository == 'github/docs-internal' && | |
(github.event_name != 'workflow_run' || | |
github.event.workflow_run.conclusion == 'success') | |
}} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: ./.github/actions/node-npm-setup | |
- name: Wait for production to match build number | |
run: | | |
needs=$(git rev-parse HEAD) | |
start_time=$(date +%s) | |
timeout_seconds=1200 | |
while [[ $needs != $(curl -s --fail --retry-connrefused --retry 5 https://docs.github.com/_build) ]] | |
do | |
if [[ $(($(date +%s) - $start_time)) -gt $timeout_seconds ]] | |
then | |
echo "Production did not match the build number within $timeout_seconds seconds" | |
exit 1 | |
fi | |
echo "Production is not up to date with the build commit" | |
sleep 10 | |
done | |
echo "Production is up to date with the build commit" | |
- name: Purge Fastly edge cache independent of language | |
if: ${{ inputs.nuke_all }} | |
run: npm run purge-fastly-edge-cache | |
- name: Purge Fastly edge cache per language | |
if: ${{ !inputs.nuke_all }} | |
env: | |
LANGUAGES: ${{ inputs.languages }} | |
run: npm run purge-fastly-edge-cache-per-language | |
- uses: ./.github/actions/slack-alert | |
if: ${{ failure() && github.event_name != 'workflow_dispatch' }} | |
with: | |
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} | |
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} |