.gitlab-ci.yml 1.43 KB
Newer Older
James T. Lee's avatar
James T. Lee committed
1
2
3
4
5
6
7
---
stages:
  - 'sync'
  - 'build'

'Sync Portage':
  stage: 'sync'
8
9
  rules:
    - if: '$BUILD_IMAGE != "1"'
James T. Lee's avatar
James T. Lee committed
10
11
12
13
14
  script:
    # Config
    - 'git config --global user.name "Nest CI"'
    - 'git config --global user.email nest@james.tl'
    - 'eval $(ssh-agent -s)'
James T. Lee's avatar
James T. Lee committed
15
16
17
    - 'chmod 600 "$SSH_PRIVATE_KEY" && ssh-add "$SSH_PRIVATE_KEY"'
    - 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'
    - 'cat "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts'
James T. Lee's avatar
James T. Lee committed
18
19
20
21
22
23
24
25

    # Sync
    - 'rsync --verbose
             --checksum
             --recursive
             --links
             --executability
             --delete
26
             --exclude-from=.dockerignore
James T. Lee's avatar
James T. Lee committed
27
28
29
30
             --progress
             rsync://rsync.us.gentoo.org/gentoo-portage/ .'

    # Verify
James T. Lee's avatar
James T. Lee committed
31
    - 'gemato verify -K /usr/share/openpgp-keys/gentoo-release.asc --keep-going'
James T. Lee's avatar
James T. Lee committed
32
    - 'find . -name Manifest.gz -delete'
James T. Lee's avatar
James T. Lee committed
33
34
35
36
37
38
    - 'rm -f Manifest Manifest.files.gz'

    # Push
    - 'git add .'
    - 'git commit -m "$(date -I) snapshot"'
    - 'git remote set-url origin git@gitlab.james.tl:nest/gentoo/portage.git'
39
    - 'git push -o ci.variable="BUILD_IMAGE=1" origin "HEAD:${CI_COMMIT_BRANCH}"'
James T. Lee's avatar
James T. Lee committed
40
41

'Build Image':
James T. Lee's avatar
James T. Lee committed
42
  image: '${CI_REGISTRY}/nest/tools/buildah:${CI_HOST_CPU}'
43
44
45
  stage: 'build'
  rules:
    - if: '$BUILD_IMAGE == "1"'
James T. Lee's avatar
James T. Lee committed
46
  script:
James T. Lee's avatar
James T. Lee committed
47
    - 'buildah login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"'
48
    - 'buildah bud --pull -t "$CI_REGISTRY_IMAGE" -f .Containerfile .'
James T. Lee's avatar
James T. Lee committed
49
    - 'buildah push "$CI_REGISTRY_IMAGE"'