Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore everything
**

# Except what we need
!bot
!pyproject.toml
!uv.lock
28 changes: 8 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
name: Build and deploy a Docker image

on:
workflow_run:
workflows: ["Linting"]
branches:
- master
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

workflow_call:
inputs:
sha-tag:
description: "A short-form SHA tag for the commit that triggered this workflow"
required: true
type: string

jobs:
build:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
name: Build & Push to GHCR
runs-on: ubuntu-latest
steps:
- name: Create a short SHA tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"

- name: Checkout code
uses: actions/checkout@v6

Expand All @@ -43,11 +31,11 @@ jobs:
with:
context: .
file: Dockerfile
push: true
push: ${{ github.ref == 'refs/heads/master' }}
cache-from: type=registry,ref=ghcr.io/fisher60/friendo-bot:latest
cache-to: type=inline
tags: |
ghcr.io/fisher60/friendo-bot:latest
ghcr.io/fisher60/friendo-bot:${{ steps.sha_tag.outputs.tag }}
ghcr.io/fisher60/friendo-bot:${{ inputs.sha-tag }}
build-args: |
git_sha=${{ github.sha }}
10 changes: 1 addition & 9 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
name: Linting

on:
push:
branches:
- master
- develop
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
workflow_call:

jobs:
lint:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
generate-sha-tag:
runs-on: ubuntu-latest
outputs:
sha-tag: ${{ steps.sha-tag.outputs.sha-tag }}
steps:
- name: Create short SHA to be used as a container tag
id: sha-tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "sha-tag=$tag" >> $GITHUB_OUTPUT

lint:
uses: ./.github/workflows/linting.yml

build-deploy:
uses: ./.github/workflows/build.yml
needs:
- lint
- generate-sha-tag
with:
sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }}
secrets: inherit
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# Copy the source code in last to optimize rebuilding the image
WORKDIR /app
COPY bot .
COPY . .

Check warning on line 36 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-deploy / Build & Push to GHCR

Attempting to Copy file that is excluded by .dockerignore

CopyIgnoredFile: Attempting to Copy file "." that is excluded by .dockerignore More info: https://docs.docker.com/go/dockerfile/rule/copy-ignored-file/

ENTRYPOINT ["python", "-m"]
CMD ["bot"]