Commit a766649d authored by Dom Sekotill's avatar Dom Sekotill
Browse files

New Gitlab-CI script

parent 6e354cd5
Loading
Loading
Loading
Loading
+31 −27
Original line number Diff line number Diff line
stages:
  - prepare
  - process
  - cleanup

make image:
  stage: prepare
  except:
    - pushes
  image: "docker:latest"
  script: docker build -t $CI_COMMIT_SHA .gitlab-ci.d

update submodules:
  stage: process
  stage: build
  except:
    - pushes
  image: "$CI_COMMIT_SHA"
  image:
    name: alpine/git
    entrypoint: [""]
  variables:
    GIT_SUBMODULE_STRATEGY: normal
  before_script:
    - git config user.name "${GITLAB_USER_NAME}"
    - git config user.email "${GITLAB_USER_EMAIL}"
  script:
    - git checkout -B master origin/master
    - . "$CI_PROJECT_DIR"/.shell/funcs
    - update_repos
    - git push git@code.kodo.org.uk:dom/dotfiles.git HEAD
    - |
      git submodule foreach --recursive '
        setting="submodule.${name}.auto-update";
        branch=`git config -f ~/.gitmodules ${setting}`;
        git checkout origin/${branch:-master} || exit 1
        (cd ${toplevel}; exec git add ${path})
      '
    - |
      git commit -m "
      Update submodules

untag image:
  stage: cleanup
  when: always
  except:
    - pushes
  image: "docker:latest"
  script:
    - docker image tag $CI_COMMIT_SHA $CI_PROJECT_NAME-$CI_PROJECT_ID
    - docker image rm $CI_COMMIT_SHA
      `git status --short -uno`

      Automatically generated:
        source: Gitlab CI
        runner: ${CI_RUNNER_DESCRIPTION} (${CI_RUNNER_VERSION})
        job:    ${CI_JOB_URL} (#${CI_JOB_ID})
        time:   `date`
      "
  after_script:
    - git push
      ${CI_PROJECT_URL/:\/\//:\/\/gitlab-ci-token:${PUSH_TOKEN?PUSH_TOKEN must be defined and allowed for ${CI_COMMIT_REF_NAME}}@}
      HEAD:${CI_COMMIT_REF_NAME}