2019-06-10 08:27:55 +00:00
|
|
|
stages:
|
|
|
|
- deploy_stage
|
2020-10-08 02:53:27 +00:00
|
|
|
- pages_stage
|
2019-06-10 08:27:55 +00:00
|
|
|
- failed_stage
|
|
|
|
|
2019-05-11 09:19:25 +00:00
|
|
|
image: alpine:latest # Use the latest version of Alpine Linux docker image
|
2018-10-09 06:18:46 +00:00
|
|
|
|
2019-06-10 08:27:55 +00:00
|
|
|
deploy_job:
|
|
|
|
stage: deploy_stage
|
|
|
|
|
|
|
|
before_script:
|
2020-04-19 07:25:58 +00:00
|
|
|
- 'which ssh-agent || (apk update && apk add curl openssh-client git grep)'
|
2020-04-20 09:05:03 +00:00
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
|
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
|
|
- chmod 644 ~/.ssh/known_hosts
|
2018-10-09 06:18:46 +00:00
|
|
|
|
2019-10-02 00:46:28 +00:00
|
|
|
script:
|
|
|
|
- sh script.sh
|
2018-10-09 06:18:46 +00:00
|
|
|
|
2019-10-02 23:57:05 +00:00
|
|
|
- git checkout master
|
2019-06-10 08:27:55 +00:00
|
|
|
- git config --global user.name "curben-bot"
|
2019-10-03 00:12:21 +00:00
|
|
|
- git config --global user.email "3048979-curben-bot@users.noreply.gitlab.com"
|
2018-10-09 06:18:46 +00:00
|
|
|
|
2019-05-28 00:21:49 +00:00
|
|
|
# Commit the changes
|
2019-05-28 00:31:09 +00:00
|
|
|
- sh utils/commit.sh
|
2019-05-28 00:21:49 +00:00
|
|
|
|
2019-10-01 11:57:48 +00:00
|
|
|
# Generate successful status badge
|
|
|
|
- mkdir -p .gitlab/
|
2020-04-01 09:33:08 +00:00
|
|
|
- sh utils/badge.sh "success"
|
2019-10-01 11:57:48 +00:00
|
|
|
- git add .gitlab/status.svg
|
|
|
|
# Only commit when diff exists https://stackoverflow.com/a/8123841
|
|
|
|
- git diff-index --quiet HEAD || git commit -m "Success pipeline"
|
|
|
|
|
2019-10-02 00:46:28 +00:00
|
|
|
- ssh -T git@gitlab.com
|
|
|
|
- git remote set-url origin git@gitlab.com:curben/urlhaus-filter.git
|
2019-10-01 12:08:37 +00:00
|
|
|
- git push origin master
|
2018-10-09 06:18:46 +00:00
|
|
|
|
2020-04-20 10:17:53 +00:00
|
|
|
rules:
|
|
|
|
# Only trigger through schedule job in master branch
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"'
|
|
|
|
when: always
|
|
|
|
# Only trigger through "Run pipeline" in master branch
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "web"'
|
|
|
|
when: always
|
2019-06-10 08:27:55 +00:00
|
|
|
|
2020-05-14 09:44:25 +00:00
|
|
|
# Upload working folder as a job artifact
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- tmp/
|
|
|
|
|
2019-06-10 08:27:55 +00:00
|
|
|
failed_job:
|
|
|
|
stage: failed_stage
|
|
|
|
|
2019-10-02 00:46:28 +00:00
|
|
|
before_script:
|
2020-04-19 07:25:58 +00:00
|
|
|
- 'which ssh-agent || (apk update && apk add curl openssh-client git grep)'
|
2019-10-01 11:57:48 +00:00
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- chmod 700 ~/.ssh
|
|
|
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
|
|
|
- chmod 644 ~/.ssh/known_hosts
|
2019-10-02 00:46:28 +00:00
|
|
|
|
|
|
|
script:
|
2020-04-01 09:14:30 +00:00
|
|
|
- git checkout master
|
2020-04-01 09:06:23 +00:00
|
|
|
- git config --global user.name "curben-bot"
|
|
|
|
- git config --global user.email "3048979-curben-bot@users.noreply.gitlab.com"
|
2020-04-01 09:14:30 +00:00
|
|
|
|
|
|
|
- mkdir -p .gitlab/
|
2020-04-01 09:33:08 +00:00
|
|
|
- sh utils/badge.sh "failed"
|
2019-10-01 11:57:48 +00:00
|
|
|
- git add .gitlab/status.svg
|
2019-10-01 12:00:34 +00:00
|
|
|
- git diff-index --quiet HEAD || git commit -m "Failed pipeline"
|
2019-10-02 00:46:28 +00:00
|
|
|
- ssh -T git@gitlab.com
|
|
|
|
- git remote set-url origin git@gitlab.com:curben/urlhaus-filter.git
|
2019-10-01 12:08:37 +00:00
|
|
|
- git push origin master
|
2019-06-10 08:27:55 +00:00
|
|
|
|
2020-04-20 10:17:53 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"'
|
2020-04-20 10:30:48 +00:00
|
|
|
# Run this job only when deploy_job failed
|
|
|
|
when: on_failure
|
2020-04-20 10:17:53 +00:00
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "web"'
|
2020-04-20 10:30:48 +00:00
|
|
|
when: on_failure
|
2020-10-08 02:53:27 +00:00
|
|
|
|
|
|
|
pages:
|
|
|
|
stage: pages_stage
|
|
|
|
|
|
|
|
script:
|
|
|
|
- mkdir -p public/
|
|
|
|
- cp urlhaus-filter-* public/
|
|
|
|
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- public
|
|
|
|
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule"'
|
|
|
|
when: always
|
|
|
|
- if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "web"'
|
|
|
|
when: always
|