Commit 38d04c51 authored by narinder Rana's avatar narinder Rana
Browse files

automate update from Upstream

parent fcee1f26
Pipeline #192227 passed with stage
in 2 minutes and 1 second
image: "registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:legacy"
stages:
- update-from-upstream
- build
before_script:
......@@ -21,3 +22,57 @@ build:
artifacts:
paths:
- app/build/outputs/apk/standard/
.update-from-upstream:
image: registry.gitlab.e.foundation/e/tools/docker-tools:latest
stage: update-from-upstream
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_REF_NAME == $LOCAL_BRANCH'
variables:
CI_PROJECT_SSH_URL: git@gitlab.e.foundation:$CI_PROJECT_PATH
GIT_STRATEGY: none
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "${SSH_E_ROBOT_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "${SSH_KNOWN_HOSTS}" > ~/.ssh/known_hosts
- echo "${SSH_KNOWN_HOSTS}"
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email $GITLAB_USER_EMAIL
- git config --global user.name "$GITLAB_USER_NAME"
- cd $CI_BUILD_DIR
- rm -rf $CI_PROJECT_DIR
- git clone $CI_PROJECT_SSH_URL $CI_PROJECT_DIR
- cd $CI_PROJECT_DIR
script:
# update $UPSTREAM_BRANCH & tags
- git fetch origin
- git checkout $UPSTREAM_BRANCH
- git remote add upstream $UPSTREAM_URL
- git fetch upstream
- git pull upstream $UPSTREAM_DEFAULT_BRANCH
- git push origin $UPSTREAM_BRANCH
- git push origin --tags
# checkout to latest tag commit to $TEMP_LATEST_TAG_BRANCH
- git checkout $(git describe --tags --abbrev=0)
- git checkout -b $TEMP_LATEST_TAG_BRANCH
# merge $LOCAL_BRANCH with $TEMP_LATEST_TAG_BRANCH & push
- git checkout $LOCAL_BRANCH
- git merge $TEMP_LATEST_TAG_BRANCH
- git push origin $LOCAL_BRANCH
# remove unwanted local branch & remote
- git branch -D $TEMP_LATEST_TAG_BRANCH
- git remote remove upstream
update-default-branch:
extends: .update-from-upstream
variables:
LOCAL_BRANCH: main
UPSTREAM_BRANCH: upstream/dev-ose
UPSTREAM_DEFAULT_BRANCH: dev-ose
UPSTREAM_URL: https://github.com/bitfireAT/davx5-ose.git
TEMP_LATEST_TAG_BRANCH: latest_upstream_tag_branch
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment