Blocking pushes to master
Adding pipeline.yml file Adding pipeline.yml file Adding pipeline.yml file only lint for python errors Add all necessary python modules for linting trying with docker in docker image trying pipelines again Updating docker password variable updating build step tags Try with build and deploy as one step Fix paramenter Fix runner tag Delete bitbucket-pipelines.yml
This commit is contained in:
parent
994c3c9f96
commit
b75a1402d8
31
.gitlab-ci.yml
Normal file
31
.gitlab-ci.yml
Normal file
@ -0,0 +1,31 @@
|
||||
image: docker:latest
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
before_script:
|
||||
- apk add --no-cache python3
|
||||
- pip3 install pylint requests discord.py docker pybooru pylint wolframalpha
|
||||
|
||||
stages:
|
||||
- test
|
||||
- deploy
|
||||
|
||||
linting_python:
|
||||
stage: test
|
||||
script:
|
||||
- pylint -E app/*.py
|
||||
only:
|
||||
- /.*/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
build_and_push_container:
|
||||
stage: deploy
|
||||
script:
|
||||
- docker login -u ldooks -p $DOCKER_PASSWORD
|
||||
- docker build -t ldooks/dragon-bot:latest .
|
||||
- docker push ldooks/dragon-bot:latest
|
||||
only:
|
||||
- master
|
||||
tags:
|
||||
- docker
|
@ -1,32 +0,0 @@
|
||||
# This is a sample build configuration for Docker.
|
||||
# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
|
||||
# Only use spaces to indent your .yml configuration.
|
||||
# -----
|
||||
# You can specify a custom docker image from Docker Hub as your build environment.
|
||||
# image: atlassian/default-image:latest
|
||||
|
||||
# enable Docker for your repository
|
||||
options:
|
||||
docker: true
|
||||
|
||||
image: python:3.6.2
|
||||
pipelines:
|
||||
default:
|
||||
- step:
|
||||
script:
|
||||
- echo "Making sure the python actually runs"
|
||||
- pip install docker discord.py pybooru requests pylint
|
||||
- python dragon-bot.py test
|
||||
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
||||
# build the Docker image (this will use the Dockerfile in the root of the repo)
|
||||
- docker build -t $IMAGE_NAME .
|
||||
branches:
|
||||
master:
|
||||
- step:
|
||||
script:
|
||||
- export IMAGE_NAME=ldooks/dragon-bot:latest
|
||||
- docker build -t $IMAGE_NAME .
|
||||
# authenticate with the Docker Hub registry
|
||||
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
|
||||
# push the new Docker image to the Docker registry
|
||||
- docker push $IMAGE_NAME
|
@ -1,3 +1,25 @@
|
||||
# Add the git hooks to the local repo. This prevents pushes on master
|
||||
SCRIPTDIR="$(dirname "$0")"
|
||||
HOOKDIR="$SCRIPTDIR/.git/hooks"
|
||||
SCRIPT="$HOOKDIR/pre-push"
|
||||
cat << EOF > $SCRIPT
|
||||
#!/bin/bash
|
||||
protected_branch='master'
|
||||
# check each branch being pushed
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
remote_branch=$(echo $remote_ref | sed -e 's,.*/\(.*\),\1,')
|
||||
if [ $protected_branch = $remote_branch ]
|
||||
then
|
||||
echo "ABORT PUSH: Not allowed to push directly to $protected_branch. Use --no-verify to force."
|
||||
exit 1 # push will not execute
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
chmod +x $SCRIPT
|
||||
|
||||
# Remove the running container so we cna re-use the container name 'dragon-bot'
|
||||
printf "\n[-] Deleting old dragon-bot container from system\n"
|
||||
docker rm -f dragon-bot-test
|
||||
|
Loading…
x
Reference in New Issue
Block a user