Skip to content

Commit

Permalink
Containerized billing and added workflow to build Docker image
Browse files Browse the repository at this point in the history
The container expects the user to provide several environment variables. More details in the Dockerfile and `clone_nonbillables_and_process.sh`.
  • Loading branch information
QuanMPhm committed May 2, 2024
1 parent 2b04771 commit 937ef17
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [main]
# Publish semver tags as releases.
tags: ['v*.*.*']
pull_request:
branches: [main]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.11-slim

WORKDIR /app

RUN apt-get update && apt-get install -y git

COPY tools/ tools/
COPY requirements.txt .
COPY process_report/process_report.py process_report/
COPY process_report/institute_map.json process_report/

RUN pip install -r requirements.txt

CMD ["tools/clone_nonbillables_and_process_invoice.sh"]
8 changes: 7 additions & 1 deletion tools/clone_nonbillables_and_process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ fi

INVOICE_MONTH=$(date --date="$(date +%Y-%m-01) -1 month" +%Y-%m)
python process_report/process_report.py \
--fetch-from-s3 \
--upload-to-s3 \
--invoice-month $INVOICE_MONTH \
--pi-file ./non-billable-projects/pi.txt \
--projects-file ./non-billable-projects/projects.txt \
--timed-projects-file ./non-billable-projects/timed_projects.txt \
--old-pi-file old_pi.csv
--nonbillable-file "NERC (Nonbillable).csv" \
--output-file "NERC.csv" \
--output-folder "PI Invoices" \
--BU-invoice-file "NERC BU.csv" \
--Lenovo-file "Lenovo.csv"

0 comments on commit 937ef17

Please sign in to comment.