Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Only delete docs preview on PR close if one is generated (#1206)
Madison Swain-Bowden02b4c870db16
diff --git a/.github/workflows/pr_closed.yml b/.github/workflows/pr_closed.ymlindex 83604fdfc..bb4e7057d 100644--- a/.github/workflows/pr_closed.yml+++ b/.github/workflows/pr_closed.yml@@ -15,10 +15,22 @@ jobs:with:ref: gh-pages+ - name: Determine if cleaning is necessary+ id: should-clean+ run: |+ if [ -d "_preview/${{ github.event.pull_request.number }}" ]; then+ echo "PR preview exists, cleaning"+ echo "clean=true" >> "$GITHUB_OUTPUT"+ else+ echo "PR preview does not exist, skipping"+ echo "clean=false" >> "$GITHUB_OUTPUT"+ fi+- name: Remove PR previewrun: rm -rf _preview/${{ github.event.pull_request.number }}- name: Push cleaned branch+ if: ${{ steps.should-clean.outputs.clean == 'true' }}run: |git config --global user.name 'PR Closed action'git config --global user.email '[email protected]'diff --git a/documentation/meta/ci_cd/jobs/documentation.md b/documentation/meta/ci_cd/jobs/documentation.mdindex a0cec44b8..77eda87bf 100644--- a/documentation/meta/ci_cd/jobs/documentation.md+++ b/documentation/meta/ci_cd/jobs/documentation.md@@ -29,3 +29,10 @@ Documentation is only emitted if all the following conditions are met.- all the primary tests ([`test-cat`](#test-cat), [`test-ing`](#test-ing),[`test-api`](#test-api), [`nuxt-build`](#nuxt-build)) succeeded, implying thattheir changes are valid, or were skipped, implying that they have no changes.++## `clean-gh-pages`++This job is executed when a PR is closed+([see the GitHub workflow](https://github.com/WordPress/openverse/blob/main/.github/workflows/pr_closed.yml)).+If a docs preview was generated, this job deletes the preview and pushes the+removal commit to the associated branch.