Skip to content

Commit

Permalink
Adding CI/CD (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Hemstreet <jon.hemstreet@unanet.com>
Co-authored-by: Nathan Zender <github@nathanzender.com>
  • Loading branch information
3 people authored Sep 11, 2024
1 parent 487514d commit ed4b1b3
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish Docker image

on:
release:
types: [published]

jobs:
publish_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: hunyadi/md2conf
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: Dockerfile_dist
tags: "latest,${{ github.ref_name }}"
27 changes: 27 additions & 0 deletions .github/workflows/publish-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Python Package

on:
release:
types: [published]

jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install build
- name: Build package
run: |
python -m build --wheel --sdist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_ID_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__
/*.egg-info
.envrc
.venv
.idea
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.9
FROM python:${PYTHON_VERSION}-alpine
RUN python3 -m pip install --upgrade pip
COPY dist/*.whl dist/
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile_dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG PYTHON_VERSION=3.9

FROM python:${PYTHON_VERSION}-alpine as builder

COPY ./ ./

RUN python3 -m pip install --upgrade pip && \
pip install build && \
python -m build --wheel

FROM python:${PYTHON_VERSION}-alpine as runner

COPY --from=builder /dist/*.whl dist/

RUN python3 -m pip install `ls -1 dist/*.whl` && \
apk add --update nodejs npm && \
npm install -g @mermaid-js/mermaid-cli

ENTRYPOINT ["python3", "-m", "md2conf"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,30 @@ optional arguments:
--ignore-invalid-url Emit a warning but otherwise ignore relative URLs that point to ill-specified locations.
--local Write XHTML-based Confluence Storage Format files locally without invoking Confluence API.
```

### Using the docker container

You can run the docker container via docker run or via dockerfile. Either can accept the environment variables or argument similar to the python options.
The final argument `./` is mdpath.

* `docker run --rm --name md2conf hunyadi/md2conf -d instructure.atlassian.net -u levente.hunyadi@instructure.com -a 0123456789abcdef -s DAP ./`

Note that the entrypont for the docker container's base image is `ENTRYPOINT ["python3", "-m", "md2conf"]`
```Dockerfile
FROM hunyadi/md2conf:latest

ENV CONFLUENCE_DOMAIN='instructure.atlassian.net'
ENV CONFLUENCE_PATH='/wiki/'
ENV CONFLUENCE_USER_NAME='levente.hunyadi@instructure.com'
ENV CONFLUENCE_API_KEY='0123456789abcdef'
ENV CONFLUENCE_SPACE_KEY='DAP'

CMD ["./"]
```
or via arguments

```Dockerfile
FROM hunyadi/md2conf:latest

CMD ["-d", "instructure.atlassian.net", "-u", "levente.hunyadi@instructure.com", "-a", "0123456789abcdef", "-s", "DAP", "./"]
```

0 comments on commit ed4b1b3

Please sign in to comment.