Add CI #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 image | |
run: | | |
docker build -t filipmania/urlshortener:${GITHUB_RUN_ID} . | |
docker push filipmania/urlshortener:${GITHUB_RUN_ID} | |
- name: Save the IMAGE_TAG | |
run: echo "IMAGE_TAG=${GITHUB_RUN_ID}" |