Commit 9080d142 authored by Bantel's avatar Bantel
Browse files

Merge branch 'cicd' into 'master'

Merge cicd into master

See merge request !2
parents 8fe9f434 af3fe849
Pipeline #12294 failed with stages
in 13 seconds
stages:
- lint
- test
- build
- deploy
variables:
PYTHONPATH: "${CI_PROJECT_DIR}"
DOCKERHUB_REPO: "uttamsb007/discord-bot"
###########################
# 1. LINT STAGE
###########################
lint:
stage: lint
image: python:3.10
script:
# - pip install flake8
- echo "Running linting..."
# - flake8 .
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
###########################
# 2. TEST STAGE
###########################
test:
stage: test
image: python:3.10
script:
- pip install pytest
- pytest || echo "No tests found, skipping."
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
###########################
# 3. BUILD DOCKER IMAGE
###########################
build:
stage: build
image: docker:24.0.9
tags: ["ubuntu", "vm"]
script:
- echo "Building Docker image..."
- docker build -t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA --build-arg DISCORD_TOKEN="$DISCORD_TOKEN" .
rules:
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
###########################
# 4. DEPLOY (PUSH TO DOCKERHUB)
###########################
deploy:
stage: deploy
image: docker:24.0.9
tags: ["ubuntu", "vm"]
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "Pushing to DockerHub..."
- docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
# If main branch, also push "latest"
- if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest;
docker push $DOCKERHUB_REPO:latest;
fi
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment