Skip to content

Fix CD pipeline

Fix CD pipeline #48

Workflow file for this run

name: CI
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install test dependencies
run: pip install flake8
- name: Lint code
run: flake8 --extend-ignore=E501
- name: Install app dependencies
run: pip install -r app/requirements.txt
- name: Run tests
run: python manage.py test
working-directory: app
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker images
run: |
ACC=filipmania
IMAGE=${ACC}/urlshortener
docker build -t ${IMAGE}:${GITHUB_RUN_ID} -t ${IMAGE}:latest .
docker push ${IMAGE}:${GITHUB_RUN_ID}
docker push ${IMAGE}:latest
docker build --build-arg BUILD=mssql -t ${IMAGE}:${GITHUB_RUN_ID}-mssql -t ${IMAGE}:mssql .
docker push ${IMAGE}:${GITHUB_RUN_ID}-mssql
docker push ${IMAGE}:mssql
docker build --build-arg BUILD=nginx -t ${IMAGE}:${GITHUB_RUN_ID}-nginx -t ${IMAGE}:nginx .
docker push ${IMAGE}:${GITHUB_RUN_ID}-nginx
docker push ${IMAGE}:nginx
docker pull nginx:latest
VER=$(docker run --rm nginx:latest nginx -v 2>&1 1>/dev/null | cut -d/ -f2)
docker build -t ${ACC}/nginx:${VER} -t ${ACC}/nginx:latest -f compose/Dockerfile compose
docker push ${ACC}/nginx:${VER}
docker push ${ACC}/nginx:latest
- name: Save the IMAGE_TAG
run: echo "IMAGE_TAG=${GITHUB_RUN_ID}"