Commit 05a16de4 authored by Benavides Ontiveros's avatar Benavides Ontiveros
Browse files

change gitlab cicd yaml

parent 12d8cf27
Pipeline #12163 failed with stages
in 16 seconds
...@@ -24,25 +24,25 @@ lint: ...@@ -24,25 +24,25 @@ lint:
extends: .build_template extends: .build_template
before_script: before_script:
- pip install flake8 - pip install flake8
script: script: |
- echo "Linting Python code..." echo "Linting Python code..."
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- echo "Done running Python lint stage" echo "Done running Python lint stage"
rules: rules:
- if: '$CI_COMMIT_BRANCH' # Run on any branch - if: '$CI_COMMIT_BRANCH'
when: always when: always
# ----------------- Diagnostics Stage ----------------- # ----------------- Diagnostics Stage -----------------
diag: diag:
stage: diag stage: diag
extends: .build_template extends: .build_template
script: script: |
- echo "Check Docker socket and info..." echo "Check Docker socket and info..."
- ls -l /var/run || true ls -l /var/run || true
- stat /var/run/docker.sock || true stat /var/run/docker.sock || true
- docker version || true docker version || true
- docker info || true docker info || true
rules: rules:
- if: '$CI_COMMIT_BRANCH' - if: '$CI_COMMIT_BRANCH'
when: always when: always
...@@ -54,33 +54,32 @@ build: ...@@ -54,33 +54,32 @@ build:
before_script: before_script:
- echo "Logging in to Docker registry..." - echo "Logging in to Docker registry..."
- echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin - echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
script: script: |
- echo "Building Docker image for commit: ${CI_COMMIT_SHORT_SHA}" echo "Building Docker image for commit: ${CI_COMMIT_SHORT_SHA}"
- docker build \ docker build \
--build-arg REDDIT_CLIENT_ID="$REDDIT_CLIENT_ID" \ --build-arg REDDIT_CLIENT_ID="$REDDIT_CLIENT_ID" \
--build-arg REDDIT_CLIENT_SECRET="$REDDIT_CLIENT_SECRET" \ --build-arg REDDIT_CLIENT_SECRET="$REDDIT_CLIENT_SECRET" \
-t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA . -t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
after_script: echo "Docker image built successfully!"
- echo "Docker image built successfully!"
rules: rules:
- if: '$CI_COMMIT_BRANCH' # Run build on any branch - if: '$CI_COMMIT_BRANCH'
when: always when: always
# ----------------- Deploy Stage ----------------- # ----------------- Deploy Stage -----------------
deploy: deploy:
stage: deploy stage: deploy
extends: .build_template extends: .build_template
script: script: |
- echo "Logging in to Docker registry..." echo "Logging in to Docker registry..."
- echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "Pushing Docker image to Docker Hub..." echo "Pushing Docker image to Docker Hub..."
- docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
# Optional: push latest if on default branch # Optional: push latest tag if on default branch
- if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest; docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
docker push $DOCKERHUB_REPO:latest; docker push $DOCKERHUB_REPO:latest
fi fi
rules: rules:
- if: '$CI_COMMIT_BRANCH' # Run deploy on any branch - if: '$CI_COMMIT_BRANCH'
when: always when: always
\ No newline at end of file
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