CI work
This commit is contained in:
parent
6847e5ca63
commit
de79515e59
1 changed files with 48 additions and 18 deletions
|
|
@ -1,6 +1,50 @@
|
||||||
|
variables:
|
||||||
|
# https://hub.docker.com/r/alpine/git/tags
|
||||||
|
GIT_VERSION: v2.30.1
|
||||||
|
|
||||||
|
.git:push:
|
||||||
|
after_script:
|
||||||
|
# Go to the new directory
|
||||||
|
- cd "${CI_COMMIT_SHA}"
|
||||||
|
|
||||||
|
- pwd
|
||||||
|
|
||||||
|
- ls
|
||||||
|
|
||||||
|
# Add all generated files to Git
|
||||||
|
- git add README.md
|
||||||
|
|
||||||
|
- git status
|
||||||
|
|
||||||
|
- |-
|
||||||
|
# Check if we have modifications to commit
|
||||||
|
CHANGES=$(git status --porcelain | wc -l)
|
||||||
|
|
||||||
|
if [ "$CHANGES" -gt "0" ]; then
|
||||||
|
# Show the status of files that are about to be created, updated or deleted
|
||||||
|
git status
|
||||||
|
|
||||||
|
# Commit all changes
|
||||||
|
git commit -m "${COMMIT_MESSAGE}"
|
||||||
|
|
||||||
|
# Update the repository and make sure to skip the pipeline create for this commit
|
||||||
|
git push origin "${CI_DEFAULT_BRANCH}" -o ci.skip
|
||||||
|
fi
|
||||||
|
before_script:
|
||||||
|
# Clone the repository via HTTPS inside a new directory
|
||||||
|
- git clone "https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${CI_COMMIT_SHA}"
|
||||||
|
|
||||||
|
# Set the displayed user with the commits that are about to be made
|
||||||
|
- git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"
|
||||||
|
- git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"
|
||||||
|
image:
|
||||||
|
entrypoint: [""]
|
||||||
|
name: alpine/git:${GIT_VERSION}
|
||||||
|
stage: deploy
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- render
|
- render
|
||||||
- commit
|
- deploy
|
||||||
|
|
||||||
check_readme_changes:
|
check_readme_changes:
|
||||||
stage: render
|
stage: render
|
||||||
|
|
@ -27,24 +71,10 @@ check_readme_changes:
|
||||||
- README.qmd
|
- README.qmd
|
||||||
when: always
|
when: always
|
||||||
|
|
||||||
commit_and_push:
|
deploy:
|
||||||
stage: commit
|
extends: .git:push
|
||||||
image: alpine:latest
|
|
||||||
before_script:
|
|
||||||
- apk add --no-cache git
|
|
||||||
script:
|
script:
|
||||||
- |
|
- mv README.md "${CI_COMMIT_SHA}/"
|
||||||
if git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep -q 'README.qmd'; then
|
|
||||||
git config --global user.email "ci@example.com"
|
|
||||||
git config --global user.name "CI Bot"
|
|
||||||
git remote remove origin
|
|
||||||
git remote add origin https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
|
|
||||||
git add README.md
|
|
||||||
git commit -m "[ci skip]: maj auto du README.md après rendu Quarto"
|
|
||||||
git push origin HEAD:$CI_COMMIT_REF_NAME
|
|
||||||
else
|
|
||||||
echo "Aucun commit/push nécessaire."
|
|
||||||
fi
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- check_readme_changes
|
- check_readme_changes
|
||||||
rules:
|
rules:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue