Skip to content

Commit 3124c31

Browse files
author
Adriano Sanges
committed
Update GitHub Actions workflow to build and push Docker image
- Replace Python project execution steps with Docker build and push actions - Set up Docker Buildx and login to GitHub Container Registry - Extract metadata for Docker image tagging and build the image - Remove previous steps related to UV and Python environment setup
1 parent d59a8ff commit 3124c31

File tree

2 files changed

+68
-45
lines changed

2 files changed

+68
-45
lines changed

.github/workflows/run-project.yml

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,44 @@
1-
name: Run Python Project with UV
1+
name: Build and Push Docker Image
22

33
on:
44
push:
55
branches:
66
- main
7-
schedule:
8-
- cron: "0 */3 * * *"
97

108
jobs:
11-
run-python:
9+
docker-build:
1210
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
1314

1415
steps:
1516
- name: Checkout Repository
1617
uses: actions/checkout@v4
1718

18-
- name: Install UV
19-
run: |
20-
curl -LsSf https://astral.sh/uv/install.sh | sh
21-
echo "$HOME/.local/bin" >> $GITHUB_PATH
22-
23-
- name: Set up Python Environment with UV
24-
run: uv venv .venv
25-
26-
- name: Install Dependencies
27-
run: |
28-
cd real-estate-etl
29-
uv lock
30-
31-
- name: Create .env File
32-
run: |
33-
echo "warehouse_name=${{ secrets.warehouse_name }}" > .env
34-
echo "motherduck_token=${{ secrets.motherduck_token }}" >> .env
35-
echo "scrape_url=${{ secrets.scrape_url }}" >> .env
36-
echo "telegram_bot_api_key=${{ secrets.telegram_bot_api_key }}" >> .env
37-
echo "chat_id=${{ secrets.chat_id }}" >> .env
38-
echo "chat_tag=${{ secrets.chat_tag }}" >> .env
39-
- name: Run Python Script
40-
env:
41-
warehouse_name: ${{ secrets.warehouse_name }}
42-
motherduck_token: ${{ secrets.motherduck_token }}
43-
scrape_url: ${{ secrets.scrape_url }}
44-
telegram_bot_api_key: ${{ secrets.telegram_bot_api_key }}
45-
chat_id: ${{ secrets.chat_id }}
46-
chat_tag: ${{ secrets.chat_tag }}
47-
run: |
48-
cd real-estate-etl
49-
uv run scan_properties.py
50-
51-
- name: Run SQLMesh
52-
env:
53-
motherduck_token: ${{ secrets.motherduck_token }}
54-
run: |
55-
cd real-estate-sqlmesh
56-
uv lock
57-
uv run sqlmesh plan
58-
uv run sqlmesh run
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Login to GitHub Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata for Docker
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ghcr.io/${{ github.repository }}
34+
tags: |
35+
type=sha,format=short
36+
type=raw,value=latest
37+
38+
- name: Build and Push Docker image
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
# Install UV
6+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
7+
8+
# Copy requirements files
9+
COPY real-estate-etl/requirements.txt .
10+
COPY real-estate-sqlmesh/requirements.txt ./sqlmesh-requirements.txt
11+
12+
# Install dependencies
13+
RUN /root/.local/bin/uv pip install -r requirements.txt
14+
RUN /root/.local/bin/uv pip install -r sqlmesh-requirements.txt
15+
16+
# Copy project files
17+
COPY real-estate-etl/ ./real-estate-etl/
18+
COPY real-estate-sqlmesh/ ./real-estate-sqlmesh/
19+
20+
# Set build arguments
21+
ARG WAREHOUSE_NAME
22+
ARG MOTHERDUCK_TOKEN
23+
ARG SCRAPE_URL
24+
ARG TELEGRAM_BOT_API_KEY
25+
ARG CHAT_ID
26+
ARG CHAT_TAG
27+
28+
# Set environment variables
29+
ENV WAREHOUSE_NAME=$WAREHOUSE_NAME
30+
ENV MOTHERDUCK_TOKEN=$MOTHERDUCK_TOKEN
31+
ENV SCRAPE_URL=$SCRAPE_URL
32+
ENV TELEGRAM_BOT_API_KEY=$TELEGRAM_BOT_API_KEY
33+
ENV CHAT_ID=$CHAT_ID
34+
ENV CHAT_TAG=$CHAT_TAG
35+
36+
# Run the script
37+
CMD ["python", "real-estate-etl/scan_properties.py"]

0 commit comments

Comments
 (0)