Skip to content

Instantly share code, notes, and snippets.

@c1982
Created March 31, 2019 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c1982/b1d0eaa95d12e7e77ff20e464f8f8191 to your computer and use it in GitHub Desktop.
Save c1982/b1d0eaa95d12e7e77ff20e464f8f8191 to your computer and use it in GitHub Desktop.
image: docker
services:
- docker:dind
stages:
- gosec
- build
variables:
VERSION: $CI_COMMIT_TAG
APP_NAME: md5go
REG_USERNAME: $REG_USR_SECRET
REG_PASSWORD: $REG_PASSWD_SECRET
security_check:
stage: gosec
allow_failure: true
script:
- docker run --name gosec -v $CI_PROJECT_DIR:$HOME/go/src/$APP_NAME --workdir $HOME/go/src/$APP_NAME c1982/gs -exclude=G104 -quiet -no-fail -fmt=html -out=report.html ./...
- docker inspect gosec --format='gosec exit code --> {{.State.ExitCode}}'
- docker cp gosec:$HOME/go/src/$APP_NAME/report.html .
artifacts:
when: always
paths:
- report.html
expire_in: 5 day
only:
- /^v[0-9|\.]+/
except:
- branches
tags:
- docker-runner
build:
stage: build
script:
- echo $VERSION
- docker build --build-arg VERSION=$VERSION -t $APP_NAME:$VERSION .
- docker tag $APP_NAME:$VERSION $REG_USERNAME/$APP_NAME:$VERSION
- docker login -u $REG_USERNAME -p $REG_PASSWORD
- docker push $REG_USERNAME/$APP_NAME:$VERSIONN
only:
- /^v[0-9|\.]+/
except:
- branches
tags:
- docker-runner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment