Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Specification Tools
Scripts
Commits
ac4fd31d
Commit
ac4fd31d
authored
1 year ago
by
Miguel Angel Reina Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Adding job to remove links from the web pages (needs to be run from web after deleting a tag)
parent
e79f4d1c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+22
-2
22 additions, 2 deletions
.gitlab-ci.yml
publish_on_pages.sh
+8
-6
8 additions, 6 deletions
publish_on_pages.sh
updateIndex.py
+25
-11
25 additions, 11 deletions
updateIndex.py
with
55 additions
and
19 deletions
.gitlab-ci.yml
+
22
−
2
View file @
ac4fd31d
...
...
@@ -80,8 +80,8 @@ Publish spec:
pages
:
stage
:
web
when
:
on_success
only
:
-
tags
rules
:
-
if
:
$CLEAN_WEB_PAGES == 'false' || $CLEAN_WEB_PAGES == 'true' && $CI_COMMIT_TAG
before_script
:
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=master" >> publish_on_pages.sh
...
...
@@ -96,3 +96,23 @@ pages:
artifacts
:
paths
:
-
public
pages
:
stage
:
web
when
:
on_success
rules
:
-
if
:
$CLEAN_WEB_PAGES != "false" && $CLEAN_WEB_PAGES != "true" && $CI_PIPELINE_SOURCE == "web"
before_script
:
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=master" >> publish_on_pages.sh
-
chmod +x publish_on_pages.sh
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/updateIndex%2Epy/raw?ref=master" >> updateIndex.py
-
|
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/index%2Ehtml/raw?ref=master" >> index.html
script
:
-
echo 'Publishing on pages'
-
./publish_on_pages.sh updateIndex.py $CI_PAGES_URL ${CI_PROJECT_NAME} $CLEAN_WEB_PAGES index.html $CLEAN_WEB_PAGES
artifacts
:
paths
:
-
public
\ No newline at end of file
This diff is collapsed.
Click to expand it.
publish_on_pages.sh
+
8
−
6
View file @
ac4fd31d
...
...
@@ -18,14 +18,16 @@ echo "------ Add/update content --------"
if
[
$6
==
'true'
]
;
then
echo
'Removing all web pages content...'
rm
-r
public/
*
;
el
se
el
if
[
$6
==
'false'
]
;
then
ls
public/
fi
mkdir
-p
"public/
$4
"
cp
-r
-f
"
$3_$4
.docx"
public/
$4
docker run
--rm
-v
$(
pwd
)
:/tmp
-w
/tmp
"
$DOCKER_IMAGE
"
pip
install
bs4
&&
python3
$1
"
$3_$4
"
"
$4
/
$3_$4
.docx"
"
$5
"
else
echo
'Removing entry for $6...'
rm
-r
-f
public/
$6
docker run
--rm
-v
$(
pwd
)
:/tmp
-w
/tmp
"
$DOCKER_IMAGE
"
pip
install
bs4
&&
python3
$1
-re
"
$3_$6
"
"
$4
/
$3_$4
.docx"
"
$5
"
fi
echo
"------ Zip the content and publish the zip again ------"
zip
-r
"content.zip"
"public"
...
...
This diff is collapsed.
Click to expand it.
updateIndex.py
+
25
−
11
View file @
ac4fd31d
...
...
@@ -24,10 +24,22 @@ def updateIndex(args:argparse.Namespace) -> None:
# Analyze index content with BeautifulSoup
soup
=
BeautifulSoup
(
html_content
,
'
html.parser
'
)
if
args
.
removeEntry
:
# Remove the element <li> for the document
if
args
.
documentLink
is
not
None
and
args
.
documentName
is
not
None
:
# Find the element to delete
element_to_delete
=
soup
.
find
(
'
li
'
,
text
=
args
.
documentName
)
# Check if the element is found before attempting to delete it
if
element_to_delete
:
# Remove the element from the HTML tree
element_to_delete
.
decompose
()
else
:
print
(
"
Element not found.
"
)
else
:
# Find document list
# Assume there's a list (<ul>) with id "document-list"
document_list
=
soup
.
find
(
'
ul
'
,
id
=
'
document-list
'
)
# Add the new element <li> for the new document
if
args
.
documentLink
is
not
None
and
args
.
documentName
is
not
None
:
li
=
soup
.
new_tag
(
'
li
'
)
...
...
@@ -48,6 +60,8 @@ if __name__ == '__main__':
# Parse command line arguments
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'
-re
'
,
'
--removeEntry
'
,
action
=
'
store_true
'
,
required
=
False
,
default
=
False
,
help
=
"
Indicate to remove the given entry
"
)
parser
.
add_argument
(
'
documentName
'
,
help
=
'
Document name to add to the list
'
)
parser
.
add_argument
(
'
documentLink
'
,
help
=
'
Document location to add to the list
'
)
parser
.
add_argument
(
'
indexTemplate
'
,
help
=
'
Index template document
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment