Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wasm_test
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
Container 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
Bartek Wrona
wasm_test
Commits
06feb4a8
Commit
06feb4a8
authored
9 months ago
by
Bartek Wrona
Browse files
Options
Downloads
Patches
Plain Diff
CI
parent
c0cda152
No related branches found
No related tags found
1 merge request
!6
CI
Pipeline
#94636
passed
9 months ago
Stage: deploy
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-2
2 additions, 2 deletions
.gitlab-ci.yml
npm_push_doc.sh
+48
-14
48 additions, 14 deletions
npm_push_doc.sh
with
50 additions
and
16 deletions
.gitlab-ci.yml
+
2
−
2
View file @
06feb4a8
...
...
@@ -24,7 +24,7 @@ push_to_wiki:
DIST_DIR
:
"
$CI_PROJECT_DIR/dist"
script
:
-
./npm_push_doc.sh "${CI_PROJECT_DIR}" "${CI_PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_COMMIT_REF_
SLUG
}" "${CI_COMMIT_REF_PROTECTED}"
-
./npm_push_doc.sh "${CI_PROJECT_DIR}" "${CI_PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_COMMIT_REF_
NAME
}" "${CI_COMMIT_REF_PROTECTED}"
rules
:
-
if
:
'
$CI_COMMIT_REF_PROTECTED
==
"false"'
...
...
@@ -34,7 +34,7 @@ final_push_to_wiki:
DIST_DIR
:
"
$CI_PROJECT_DIR/dist"
script
:
-
./npm_push_doc.sh "${CI_PROJECT_DIR}" "${CI_PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_
MERGE_REQUEST_SOURCE_BRANCH
_NAME}" "${CI_COMMIT_REF_PROTECTED}"
-
./npm_push_doc.sh "${CI_PROJECT_DIR}" "${CI_PROJECT_URL}" "${WIKI_PUSH_TOKEN}" "${DIST_DIR}" "${CI_
COMMIT_REF
_NAME}" "${CI_COMMIT_REF_PROTECTED}"
rules
:
-
if
:
'
$CI_COMMIT_REF_PROTECTED
==
"true"'
This diff is collapsed.
Click to expand it.
npm_push_doc.sh
+
48
−
14
View file @
06feb4a8
...
...
@@ -3,14 +3,48 @@ set -xe
SCRIPTPATH
=
"
$(
cd
--
"
$(
dirname
"
$0
"
)
"
>
/dev/null 2>&1
;
pwd
-P
)
"
perform_wiki_cleanup
()
{
local
nonstable_dir
=
"
${
1
}
"
local
repo_url
=
"
${
2
}
"
echo
"Attempting to perform feature-branch storage cleanup."
pushd
"
${
nonstable_dir
}
"
for
d
in
*
;
do
if
[
-d
"
${
d
}
"
]
;
then
echo
"Processing subdirectory
${
d
}
"
set
+e
git ls-remote
--heads
-q
--exit-code
"
${
repo_url
}
"
"refs/heads/
${
d
}
"
local
retcode
=
$?
set
-e
if
[
${
retcode
}
-eq
0
]
;
then
echo
"Branch
${
d
}
exists, skipping"
elif
[
${
retcode
}
-eq
2
]
;
then
echo
"Branch
${
d
}
does not exist. Performing documentation storage cleanup"
git
rm
-r
"
${
d
}
"
git commit
-m
"Cleanup actions done for docs placed in:
${
d
}
"
.
git push origin
"HEAD:main"
else
echo
"ERROR, git command failed"
exit
1
fi
fi
done
popd
echo
"Cleanup done."
}
PROJECT_DIR
=
"
${
1
:?Missing
arg #1 specifying a project source directory
}
"
PROJECT_URL
=
"
${
2
:?Missing
arg #2 pointing project url. It is provided by CI_PROJECT_URL variable
}
"
PROJECT_ACCESS_TOKEN
=
"
${
3
:?Missing
arg #3 pointing a Gitlab repository access token
}
"
DIST_DIR
=
"
${
4
:?Missing
arg #4 pointing the dist directory
}
"
FEATURE_BRANCH_NAME
=
"
${
5
:?Missing
arg #5 pointing the feature branch name
}
"
FEATURE_BRANCH_NAME
=
"
${
5
:?Missing
arg #5 pointing a branch name
}
"
FINAL_MERGE
=
"
${
6
:?Missing
arg #6 pointing the final merge flag value
}
"
if
[
"
${
FINAL_MERGE
}
"
=
"true"
]
;
then
...
...
@@ -19,10 +53,10 @@ else
FINAL_MERGE
=
0
fi
echo
"Using project directory:
${
PROJECT_DIR
}
"
echo
"Using project URL:
${
PROJECT_URL
}
"
echo
"Using dist dir:
${
DIST_DIR
}
"
echo
"Pushing documentation for branch:
${
FEATURE_BRANCH_NAME
}
"
echo
"Does it is a final push for default/protected branch?:
${
FINAL_MERGE
}
"
WIKI_REPO_URL
=
"
${
PROJECT_URL
}
.wiki.git"
...
...
@@ -33,11 +67,13 @@ DOC_STORAGE_DIR="${WIKI_REPO_DIR}"
pushd
"
${
PROJECT_DIR
}
"
COMMIT_AUTHOR_NAME
=
$(
git log
-1
--format
=
'%aN'
HEAD
)
COMMIT_AUTHOR_EMAIL
=
$(
git log
-1
--format
=
'%aE'
HEAD
)
COMMIT_AUTHOR_NAME
=
$(
git log
-1
--format
=
'%aN'
${
COMMIT
}
)
COMMIT_AUTHOR_EMAIL
=
$(
git log
-1
--format
=
'%aE'
${
COMMIT
}
)
popd
echo
"Pushing documentation for branch:
${
FEATURE_BRANCH_NAME
}
"
echo
"Using wiki repo:
${
WIKI_REPO_URL
}
"
git clone
"
${
WIKI_REPO_URL
}
"
"
${
WIKI_REPO_DIR
}
"
...
...
@@ -51,12 +87,14 @@ if [ ${FINAL_MERGE} -eq 1 ]; then
echo
"Attempting to push documentation to the root page"
else
echo
"Attempting to push documentation to the feature branch specific page"
DOC_STORAGE_DIR
=
"
${
DOC_STORAGE_DIR
}
/
${
FEATURE_BRANCH_NAME
}
"
DOC_STORAGE_DIR
=
"
${
WIKI_REPO_DIR
}
/non-stable
/
${
FEATURE_BRANCH_NAME
}
"
fi
echo
"Documentation storage dir:
${
DOC_STORAGE_DIR
}
"
mkdir
-vp
"
${
DOC_STORAGE_DIR
}
"
touch
"
${
WIKI_REPO_DIR
}
/non-stable/.gitkeep"
git add
"
${
WIKI_REPO_DIR
}
/non-stable/.gitkeep"
cp
-vr
"
${
DOC_INPUT_DIR
}
"
/
*
"
${
DOC_STORAGE_DIR
}
"
...
...
@@ -73,16 +111,12 @@ fi
if
[
${
FINAL_MERGE
}
-eq
1
]
;
then
DOC_URL
=
"
${
PROJECT_URL
}
/-/wikis/home"
echo
"Attempting to perform feature-branch storage cleanup."
git
rm
-r
"
${
FEATURE_BRANCH_NAME
}
"
git commit
-m
"Cleaned up already merged documentation for feature branch:
${
FEATURE_BRANCH_NAME
}
"
git push origin
"HEAD:main"
else
DOC_URL
=
"
${
PROJECT_URL
}
/-/wikis/
${
FEATURE_BRANCH_NAME
}
/home"
DOC_URL
=
"
${
PROJECT_URL
}
/-/wikis/
non-stable/
${
FEATURE_BRANCH_NAME
}
/home"
fi
perform_wiki_cleanup
"
${
WIKI_REPO_DIR
}
/non-stable"
"
${
PROJECT_URL
}
"
echo
"Documentation is available at url:
${
DOC_URL
}
"
popd
...
...
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