summarylogtreecommitdiffstats
path: root/.gitlab-ci.yml
blob: 890a2742fc98d1239a10283bac4d9306a117dfaf (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
image: node:alpine

workflow:
  name: 'Pipeline for branch: $CI_COMMIT_BRANCH'
  rules:
    - changes:
      - ${CI_CONFIG_PATH}

update:
  stage: build
  image: archlinux:base-devel
  script:
    - '[ -f "$mirrorlist" ] && cat "$mirrorlist" > /etc/pacman.d/mirrorlist'
    - pacman -Sy pacman-contrib --quiet --needed --noconfirm --noprogressbar
    - useradd deploy
    - sudo -u deploy ./update
  artifacts:
    paths:
      - "PKGBUILD"
      - ".SRCINFO"

deploy-git:
  stage: deploy
  image: bitnami/git
  script:
    - git diff --exit-code && exit 0

    - eval $(ssh-agent -s)

    - chmod 400 "$SSH_PRIVATE_KEY"
    - ssh-add "$SSH_PRIVATE_KEY"

    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh

    - ssh-keyscan -p ${CI_SERVER_SHELL_SSH_PORT} ${CI_SERVER_SHELL_SSH_HOST} >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts

    - version=`sed -n "s|^_version=||p" PKGBUILD`
    - pkgrel=`sed -n "s|^pkgrel=||p" PKGBUILD`

    - git config --remove-section user
    - git config --add user.name "${GITLAB_USER_NAME}"
    - git config --add user.email "${GITLAB_USER_EMAIL}"
    - git remote set-url origin ssh://git@${CI_SERVER_SHELL_SSH_HOST}:${CI_SERVER_SHELL_SSH_PORT}/${CI_PROJECT_PATH}.git

    - git commit -a -s -m "Auto update ver ${version}-${pkgrel}"
    - git push origin HEAD:${CI_COMMIT_BRANCH}
  needs:
    - update