urlhaus-filter/.gitlab-ci.yml

81 lines
2.4 KiB
YAML
Raw Normal View History

stages:
- test
- deploy
- failed_stage
image: alpine:latest # Use the latest version of Alpine Linux docker image
2018-10-09 06:18:46 +00:00
build_job:
stage: test
before_script:
- 'which ssh-agent || (apk update && apk add curl openssh-client git grep)'
- 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:
2022-01-07 10:35:02 +00:00
- sh src/script.sh
2018-10-09 06:18:46 +00:00
2019-10-02 23:57:05 +00:00
- git checkout master
- 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
# Commit the changes
2022-01-07 10:35:02 +00:00
- sh src/commit.sh
# Generate successful status badge
- mkdir -p .gitlab/
2022-01-07 10:35:02 +00:00
- sh src/badge.sh "success"
- 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
rules:
2020-12-12 21:43:52 +00:00
# Only trigger through schedule job and "Run pipeline" in master branch
- if: '$CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web")'
when: always
# Upload working folder as a job artifact
artifacts:
paths:
- tmp/
2021-03-18 10:20:51 +00:00
expire_in: 30 days
failed_job:
stage: failed_stage
2019-10-02 00:46:28 +00:00
before_script:
- 'which ssh-agent || (apk update && apk add curl openssh-client git grep)'
- 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/
2022-01-07 10:35:02 +00:00
- sh src/badge.sh "failed"
- 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
rules:
2020-12-12 21:43:52 +00:00
- if: '$CI_COMMIT_REF_NAME == "master" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web")'
# Run this job only when preceding jobs failed
when: on_failure