Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.73 KiB
Newer Older
stages:
  - build
  - publish
migu's avatar
migu committed
.template:build_guide:
migu's avatar
migu committed
  image: alpine
migu's avatar
migu committed
  before_script:
migu's avatar
migu committed
    - apk update
migu's avatar
migu committed
    - apk add --no-cache ruby asciidoctor git
    - gem install asciidoctor-pdf --pre
  artifacts:
    paths:
      - "angelguide_en.pdf"
      - "angelguide_de.pdf"
    expire_in: 12 months
migu's avatar
migu committed

build_guide_by_tag:
  extends: .template:build_guide
  script:
    - export COMMIT_DATE=$(git show -s --format=%ci $CI_COMMIT_SHA | cut -c1-10)
    - export REVISION=$CI_COMMIT_TAG
    - asciidoctor-pdf -a revnumber=$REVISION -a revdate=$COMMIT_DATE -o angelguide_en.pdf guide.adoc
    - asciidoctor-pdf -a revnumber=$REVISION -a revdate=$COMMIT_DATE -o angelguide_de.pdf -a lang=de guide.adoc
  rules:
    - if: $CI_COMMIT_TAG != null
      when: always
build_guide:
migu's avatar
migu committed
  extends: .template:build_guide
migu's avatar
migu committed
    - export COMMIT_DATE=$(git show -s --format=%ci $CI_COMMIT_SHA | cut -c1-10)
    - export REVISION=$CI_COMMIT_SHORT_SHA
    - asciidoctor-pdf -a revnumber=$REVISION -a revdate=$COMMIT_DATE -o angelguide_en.pdf guide.adoc
    - asciidoctor-pdf -a revnumber=$REVISION -a revdate=$COMMIT_DATE -o angelguide_de.pdf -a lang=de guide.adoc
  rules:
    - if: $CI_COMMIT_TAG == null
      when: always
publish_guide:
  stage: publish
migu's avatar
migu committed
  image: kroniak/ssh-client
  before_script:
migu's avatar
migu committed
    - apk update
migu's avatar
migu committed
    - apk add --no-cache rsync
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
migu's avatar
migu committed
    - eval $(ssh-agent -s)
migu's avatar
migu committed
    - echo -n "$SSH_PRIVATE_KEY" | ssh-add -
migu's avatar
migu committed
    - ssh-keyscan -H "$PUBLISH_HOST" >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
migu's avatar
migu committed
    - 'rsync -av angelguide_*.pdf $PUBLISH_USER@$PUBLISH_HOST:$PUBLISH_PATH'
  rules:
Chessmaster's avatar
Chessmaster committed
    - if: '$CI_COMMIT_REF_NAME == "master" && $CI_COMMIT_TAG != null'
      when: on_success
    - when: never