Added Docker build #30
Workflow file for this run
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: Python application | |
on: | |
push: | |
branches: [ master, develop ] | |
pull_request: | |
branches: [ master, develop ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10'] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
sudo apt-get -qq update | |
sudo apt-get install -y libemail-outlook-message-perl | |
pip install ".[dev, test]" | |
export PERL_MM_USE_DEFAULT=1 | |
sudo cpan -f -i Email::Outlook::Message | |
- name: Run tests | |
env: | |
PYTHONPATH: src | |
run: | | |
pytest --cov=mailparser --cov-report=xml | |
python -m mailparser -v | |
python -m mailparser -h | |
mail-parser -f tests/mails/mail_malformed_3 -j | |
cat tests/mails/mail_malformed_3 | mail-parser -k -j | |
- name: Run pre-commit | |
if: matrix.python-version == '3.10' | |
run: | | |
make pre-commit | |
- name: Report to Coveralls | |
if: matrix.python-version == '3.10' | |
uses: coverallsapp/[email protected] | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build | |
if: matrix.python-version == '3.10' | |
run: | | |
python -m build | |
- name: Upload artifacts | |
if: matrix.python-version == '3.10' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
dist/mail-parser-*.tar.gz | |
dist/mail_parser-*.whl | |
docker: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
run: | | |
IMAGE_NAME=ghcr.io/${{ github.repository }}/mailparser | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
TAG=${GITHUB_REF#refs/tags/} | |
else | |
TAG=develop | |
fi | |
docker build \ | |
--label "org.opencontainers.image.source=${{ github.repositoryUrl }}" \ | |
--label "org.opencontainers.image.description=Easy way to pass from raw mail to Python object" \ | |
--label "org.opencontainers.image.licenses=Apache-2.0" \ | |
--build-arg BRANCH=$TAG | |
-t $IMAGE_NAME:$TAG . | |
docker push $IMAGE_NAME:$TAG |