diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..d1a6093 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,60 @@ +name: Docker Build & Publish + +# This tells GitHub: "Run this every time I push code to the main branch" +on: + push: + branches: [ "main" ] + # Also run if I create a Release tag (e.g., v1.0) + tags: [ 'v*.*.*' ] + pull_request: + branches: [ "main" ] + +env: + # Use GitHub's built-in registry (ghcr.io) + REGISTRY: ghcr.io + # Use the repository name as the image name + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write # Needed to push the image to GHCR + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Set up Docker Buildx (The builder engine) + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Login to GitHub Container Registry using the automatic GitHub Token + - 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 }} + + # Generate tags (e.g., :latest, :v1.0, :main) + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=semver,pattern={{version}} + + # Build the image and push it to the registry + - 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 }} diff --git a/README.md b/README.md index a75cd32..3741895 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # 🤖 Universal Reddit Scraper +[![Docker Build & Publish](https://github.com/ksanjeev284/reddit-universal-scraper/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/ksanjeev284/reddit-universal-scraper/actions/workflows/docker-publish.yml) + A robust, dual-mode Reddit scraper designed to run on low-resource servers (like AWS Free Tier). +## 🐳 Quick Start (No Installation Needed!) +```bash +# Pull the pre-built image and run +docker run -d -v $(pwd)/data:/app/data ghcr.io/ksanjeev284/reddit-universal-scraper:latest CreditCardsIndia --mode monitor +``` + ## Features - **Zero API Keys Needed:** Uses RSS feeds and Public Mirrors (Redlib) to bypass API limits. - **Dual Modes:**