aboutsummaryrefslogtreecommitdiffstats
path: root/.github
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-08-01 21:35:10 +0100
committerGravatar Chris Lovering <[email protected]>2024-08-01 21:35:10 +0100
commit2ce2c39465f15f81a26b773def77c1f5f9b165c5 (patch)
tree0b5b72ef952b8094963f51ecd2e5a6bda95a0794 /.github
parentDisable dependabot (diff)
Enable CI
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/build.yaml42
-rw-r--r--.github/workflows/lint.yaml32
-rw-r--r--.github/workflows/main.yaml46
3 files changed, 120 insertions, 0 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..23db7e0
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,42 @@
+on:
+ workflow_call:
+ inputs:
+ sha-tag:
+ description: "A short-form SHA tag for the commit that triggered this flow"
+ required: true
+ type: string
+ lower-repo:
+ description: "The repository name in lowercase"
+ required: true
+ type: string
+
+jobs:
+ build:
+ name: Build & Push
+ runs-on: ubuntu-latest
+
+ steps:
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Github Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ github.token }}
+
+ # Build and push the container to the GitHub Container
+ # Repository. The container will be tagged as "latest"
+ # and with the short SHA of the commit.
+ - name: Build and push
+ uses: docker/build-push-action@v5
+ with:
+ push: ${{ github.ref == github.event.repository.default_branch }}
+ cache-from: type=registry,ref=ghcr.io/${{ inputs.lower-repo }}:latest
+ cache-to: type=inline
+ tags: |
+ ghcr.io/${{ inputs.lower-repo }}:latest
+ ghcr.io/${{ inputs.lower-repo }}:${{ inputs.sha-tag }}
+ build-args: git_sha=${{ github.sha }}
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml
new file mode 100644
index 0000000..2a4ea23
--- /dev/null
+++ b/.github/workflows/lint.yaml
@@ -0,0 +1,32 @@
+on:
+ workflow_call:
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Python Dependencies
+ uses: HassanAbouelela/actions/setup-python@setup-python_v1.6.0
+ with:
+ python_version: "3.12"
+ install_args: "--only linting"
+
+ - name: Ensure requirements.txt is up to date
+ shell: bash
+ run: |
+ poetry export --output temp-requirements.txt -vvv
+
+ if ! cmp -s "requirements.txt" "temp-requirements.txt"; then
+ echo "::error file=requirements.txt,title=Requirements out of date!::Run 'poetry export --output requirements.txt'"
+ exit 1
+ fi
+
+ - name: Run pre-commit hooks
+ run: SKIP=ruff-lint pre-commit run --all-files
+
+ # Run `ruff` using github formatting to enable automatic inline annotations.
+ - name: Run ruff
+ run: "ruff check --output-format=github ."
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
new file mode 100644
index 0000000..c109acd
--- /dev/null
+++ b/.github/workflows/main.yaml
@@ -0,0 +1,46 @@
+name: main
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ generate-inputs:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ shell: bash
+
+ outputs:
+ sha-tag: ${{ steps.sha-tag.outputs.sha-tag }}
+ lower-repo: ${{ steps.lower-repo.outputs.lower-repo }}
+
+ steps:
+ - name: Create SHA Container Tag
+ id: sha-tag
+ run: |
+ tag=$(cut -c 1-7 <<< $GITHUB_SHA)
+ echo "sha-tag=$tag" >> $GITHUB_OUTPUT
+ # docker/build-push-action doesn't allow capital letters in the URL
+ - name: Get repo in lowercase
+ id: lower-repo
+ run: |
+ echo "lower-repo=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
+
+ lint:
+ uses: ./.github/workflows/lint.yaml
+
+ build:
+ uses: ./.github/workflows/build.yaml
+ needs:
+ - lint
+ - generate-inputs
+ with:
+ sha-tag: ${{ needs.generate-inputs.outputs.sha-tag }}
+ lower-repo: ${{ needs.generate-inputs.outputs.lower-repo }}