Skip to content

docker workflow deleted and inserted in ci-cd pipeline #2

docker workflow deleted and inserted in ci-cd pipeline

docker workflow deleted and inserted in ci-cd pipeline #2

Workflow file for this run

name: ci-cd-pipeline
on:
push:
branches: ["main", "**"]
pull_request:
branches: ["main", "**"]
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v3
with:
python-version: 3.12.0
- name: Install dependencies
run: |
echo "Installing dependencies"
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
echo "Testing..."
python -m unittest discover -s /test -p '*_test.py'
#Run all test in test folder (ending with _test.py) OBS naming convention.
build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Build if test pass
run: |
echo "Building project"
python3 server/server.py
docker_deploy_image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}