Skip to content

Commit be4249b

Browse files
authored
Remove the concept of "undeployment" as a part of the PR deployment lifecycle (github#23731)
* Update remove-stale-staging-resources workflow to completely replace undeploy workflow * Delete the staging-undeploy-pr workflow file * Delete all undeployment scripts and logic * Remove all references to the automated-block-deploy label used for undeployment * Simplify staging cross-workflow concurrency needs
1 parent 00fc555 commit be4249b

10 files changed

+69
-425
lines changed

.github/actions-scripts/staging-undeploy.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/remove-stale-staging-resources.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ name: Remove stale staging resources
44
# This cleans up any rogue staging applications and environments that outlasted
55
# the closure of their corresponding pull requests.
66
# **Why we have it**:
7-
# Staging applications and environments sometimes fail to be destroyed when
8-
# their corresponding pull request is closed or merged.
7+
# Staging applications and environments should be destroyed after their
8+
# corresponding pull request is closed or merged, especially to save money spent
9+
# on Heroku App staging deployments for closed PRs.
910
# **Who does it impact**:
1011
# Anyone with a closed, spammy, or deleted pull request in docs or docs-internal.
1112

@@ -15,7 +16,8 @@ on:
1516

1617
permissions:
1718
contents: read
18-
pull-requests: read
19+
deployments: write
20+
pull-requests: write
1921

2022
jobs:
2123
remove_stale_staging_apps:
@@ -60,5 +62,7 @@ jobs:
6062
- name: Run script
6163
run: script/remove-stale-staging-envs.js
6264
env:
63-
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }}
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
ELEVATED_TOKEN: ${{ secrets.DOCS_BOT_FR }}
6467
REPO: ${{ github.repository }}
68+
RUN_ID: ${{ github.run_id }}

.github/workflows/staging-build-and-deploy-pr.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ permissions:
2525
statuses: write
2626

2727
# This allows a subsequently queued workflow run to interrupt previous runs
28-
# These are different from the concurrency in that here it checks if the
29-
# whole workflow runs again. The "inner concurrency" is used for
30-
# undeployments to cleaning up resources.
3128
concurrency:
3229
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
3330
cancel-in-progress: true
@@ -44,11 +41,7 @@ jobs:
4441
runs-on: self-hosted
4542

4643
timeout-minutes: 5
47-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
48-
# progress for this PR branch.
49-
concurrency:
50-
group: 'PR Staging @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
51-
cancel-in-progress: true
44+
5245
steps:
5346
- name: Check out repo
5447
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
@@ -85,15 +78,6 @@ jobs:
8578
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
8679
GIT_BRANCH: ${{ github.event.pull_request.head.sha }}
8780

88-
- name: Check that the PR isn't blocking deploys
89-
# We can't use ${{...}} on this if statement because of this bug
90-
# https://github.com/cschleiden/actions-linter/issues/114
91-
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'automated-block-deploy')
92-
run: |
93-
echo "The PR appears to have the label 'automated-block-deploy'"
94-
echo "Will not proceed to deploy the PR."
95-
exit 2
96-
9781
- name: Create a Heroku build source
9882
id: build-source
9983
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d

.github/workflows/staging-build-pr.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727

2828
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
2929
timeout-minutes: 5
30-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
31-
# progress for this PR branch.
30+
# This interrupts Build and Deploy workflow runs in progress for this PR branch.
3231
concurrency:
3332
group: 'PR Staging @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
3433
cancel-in-progress: true

.github/workflows/staging-deploy-pr.yml

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -198,68 +198,12 @@ jobs:
198198
color: failure
199199
text: Staging build failed for PR ${{ needs.pr-metadata.outputs.url }} at commit ${{ needs.pr-metadata.outputs.head_sha }}. See ${{ env.BUILD_ACTIONS_RUN_LOG }}. This run was ${{ env.ACTIONS_RUN_LOG }}.
200200

201-
check-pr-before-prepare:
202-
needs: pr-metadata
203-
if: >-
204-
${{
205-
needs.pr-metadata.outputs.number != '0' &&
206-
github.event.workflow_run.conclusion == 'success'
207-
}}
208-
runs-on: ubuntu-latest
209-
# This timeout should match or exceed the value of the timeout for Undeploy
210-
timeout-minutes: 5
211-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
212-
# progress for this PR branch.
213-
concurrency:
214-
group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}'
215-
cancel-in-progress: true
216-
outputs:
217-
pull_request_state: ${{ steps.check-pr.outputs.state }}
218-
steps:
219-
- name: Check pull request state
220-
id: check-pr
221-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
222-
env:
223-
PR_NUMBER: ${{ needs.pr-metadata.outputs.number }}
224-
with:
225-
script: |
226-
// Equivalent of the 'await-sleep' module without the install
227-
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
228-
229-
const blockingLabel = 'automated-block-deploy'
230-
const { owner, repo } = context.repo
231-
const startTime = Date.now()
232-
233-
let pullRequest = {}
234-
let blocked = true
235-
236-
// Keep polling the PR until the blocking label has been removed
237-
while (blocked) {
238-
const { data: pr } = await github.pulls.get({
239-
owner,
240-
repo,
241-
pull_number: process.env.PR_NUMBER
242-
})
243-
244-
blocked = pr.labels.some(({ name }) => name === blockingLabel)
245-
if (blocked) {
246-
console.warn(`WARNING! PR currently has blocking label "${blockingLabel}" (after ${Date.now() - startTime} ms). Will check again soon...`)
247-
await sleep(15000) // Wait 15 seconds and check again
248-
} else {
249-
console.log(`PR was unblocked (after ${Date.now() - startTime} ms)!`)
250-
pullRequest = pr
251-
}
252-
}
253-
254-
core.setOutput('state', pullRequest.state)
255-
256201
prepare-for-deploy:
257-
needs: [pr-metadata, check-pr-before-prepare]
258-
if: ${{ needs.check-pr-before-prepare.outputs.pull_request_state == 'open' }}
202+
needs: pr-metadata
203+
if: ${{ needs.pr-metadata.outputs.state == 'open' }}
259204
runs-on: ubuntu-latest
260205
timeout-minutes: 5
261-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
262-
# progress for this PR branch.
206+
# This interrupts Build and Deploy workflow runs in progress for this PR branch.
263207
concurrency:
264208
group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}'
265209
cancel-in-progress: true
@@ -395,8 +339,7 @@ jobs:
395339
needs: [pr-metadata, prepare-for-deploy]
396340
runs-on: ubuntu-latest
397341
timeout-minutes: 1
398-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
399-
# progress for this PR branch.
342+
# This interrupts Build and Deploy workflow runs in progress for this PR branch.
400343
concurrency:
401344
group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}'
402345
cancel-in-progress: true
@@ -423,8 +366,7 @@ jobs:
423366
if: ${{ needs.check-pr-before-deploy.outputs.pull_request_state == 'open' }}
424367
runs-on: ubuntu-latest
425368
timeout-minutes: 10
426-
# This interrupts Build, Deploy, and pre-write Undeploy workflow runs in
427-
# progress for this PR branch.
369+
# This interrupts Build and Deploy workflow runs in progress for this PR branch.
428370
concurrency:
429371
group: 'PR Staging @ ${{ needs.pr-metadata.outputs.head_label }}'
430372
cancel-in-progress: true

.github/workflows/staging-undeploy-pr.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)