Skip to content

Update build tooling and CI/CD pipeline #60

Update build tooling and CI/CD pipeline

Update build tooling and CI/CD pipeline #60

Workflow file for this run

name: build
# Build and test the NautilusTrader example data image
permissions: # Principle of least privilege
contents: read
on:
push:
branches: [main]
pull_request:
branches: ['*']
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@cae9d6a5c961a2c267bc955ecf8d27bc955b2e83 # v5.4.0
with:
python-version: "3.13"
- name: Install uv
# https://github.com/astral-sh/setup-uv
uses: astral-sh/setup-uv@1b6072f24a1f5e1bf6797b14bb96e52cf5e1f027 # v5.0.1
- name: Install dependencies
run: uv sync --all-groups
- name: Run pre-commit
run: uv run pre-commit run --all-files
docker-image:
runs-on: ubuntu-latest
needs:
- pre-commit
permissions:
contents: read
packages: write
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- name: Login to GHCR
if: github.event_name == 'push'
# https://github.com/docker/login-action
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Get branch name
id: branch-name
run: |
echo "current_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: docker_build
# https://github.com/docker/build-push-action
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/${{ github.repository }}:${{ steps.branch-name.outputs.current_branch }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
if: github.event_name == 'push'
run: echo ${{ steps.docker_build.outputs.digest }}