-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
27 lines (26 loc) · 1.32 KB
/
.gitlab-ci.yml
File metadata and controls
27 lines (26 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
stages:
- sync
sync-upstream:
stage: sync
image: python:3.12-slim
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "web"
before_script:
- apt-get update -qq && apt-get install -y -qq git > /dev/null
- git config --global user.email "ci@${CI_SERVER_HOST}"
- git config --global user.name "GitLab CI Sync Bot"
script:
- "git clone --depth 1 https://github.com/javaevolved/javaevolved.github.io.git /tmp/upstream"
- "YAML_COUNT=$(find /tmp/upstream/content -name '*.yaml' | wc -l | tr -d ' ')"
- "UPSTREAM_SHA=$(cd /tmp/upstream && git rev-parse --short HEAD)"
- "UPSTREAM_DATE=$(cd /tmp/upstream && git log -1 --format=%cs)"
- "echo Found $YAML_COUNT upstream patterns commit $UPSTREAM_SHA from $UPSTREAM_DATE"
- "python3 scripts/generate-references.py --content-dir /tmp/upstream/content --output-dir references/"
- "if git diff --quiet -- references/; then echo No changes detected; exit 0; fi"
- "BRANCH=sync/upstream-${UPSTREAM_SHA}"
- "git checkout -b $BRANCH"
- "git add references/"
- "git commit -m 'chore: sync references from upstream'"
- "git remote set-url origin https://oauth2:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- "git push -o merge_request.create -o merge_request.remove_source_branch origin $BRANCH"