Fix Pages Deployments related to an MR not being deleted
What does this MR do and why?
This MR fixes an issue with the Pages Multiple Deployments feature where Pages Deployments would not be deleted if the related MR was closed or merged.
How to set up and validate locally
- Set up your GDK to support Runners and Pages
- Enable the feature flag with
echo "Feature.enable(\"pages_multiple_versions_setting\")" | rails c
- Create a Pages project, by creating a new project with the "pages/Plain HTML" template.
- Replace the below config in the
.gitlab-ci.yml
:
# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
image: busybox
pages:
stage: deploy
script:
- echo "Pages accessible through ${CI_PAGES_URL}/${PAGES_PREFIX}"
variables:
PAGES_PREFIX: "" # no prefix by default (master)
pages:
path_prefix: "$PAGES_PREFIX"
artifacts:
paths:
- public
environment:
name: "Pages ${PAGES_PREFIX}"
url: "${CI_PAGES_URL}/${PAGES_PREFIX}"
rules:
- if: $CI_COMMIT_BRANCH == "master" # ensure to run on master (with default PAGES_PREFIX)
variables:
PAGES_PREFIX: '' # prefix with _stg for the staging branch
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # conditionally change the prefix on Merge Requests
variables:
PAGES_PREFIX: 'mr$CI_MERGE_REQUEST_IID' # prefix with the mr<iid>, like `mr123`
- Ensure the pipeline runs successfully and you have a pages deployment
- Create an MR in the project. Ensure the MR's pipeline creates a Pages deployment.
- View the MR's deployment at
http[s]://<PAGE_URL>/mr<MR_ID>
. Keep this link for later. - Close the MR
- Wait a little while, then confirm the deployment is no longer accessible under the above link.
- Repeat steps 6-9, but this time merge the MR instead of closing.
Edited by Janis Altherr