Skip to content

Commit

Permalink
refactor: simplify GitHub Actions workflows by removing Docker image …
Browse files Browse the repository at this point in the history
…build steps and using Python directly
  • Loading branch information
Flexicon committed Jan 11, 2025
1 parent 3aa0943 commit 6020ae7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 53 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/run_scraper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ on:
scraper:
required: true
type: string
image_name:
required: true
type: string

jobs:
run_scraper:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Run worker
uses: nick-fields/retry@3f757583fb1b1f940bc8ef4bf4734c8dc02a5847
env:
Expand All @@ -26,6 +28,4 @@ jobs:
max_attempts: 10
retry_on: error
command: |
docker run -e DB_NAME -e MONGODB_URI \
-v /dev/shm:/dev/shm \
--rm ${{ inputs.image_name }} python3 -m scraper.${{ inputs.scraper }}
python -m scraper.${{ inputs.scraper }}
47 changes: 0 additions & 47 deletions .github/workflows/worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,23 @@ env:
IMAGE_NAME: flexicon/tft-suggester/worker

jobs:
build_image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@5138f76647652447004da686b2411557eaf65f33
name: Setup buildx
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

scrape_champions:
uses: ./.github/workflows/run_scraper.yml
needs: build_image
secrets: inherit
with:
scraper: scrape_champions
image_name: ghcr.io/flexicon/tft-suggester/worker

scrape_comps:
uses: ./.github/workflows/run_scraper.yml
needs: build_image
secrets: inherit
with:
scraper: scrape_comps
image_name: ghcr.io/flexicon/tft-suggester/worker

scrape_items:
uses: ./.github/workflows/run_scraper.yml
needs: build_image
secrets: inherit
with:
scraper: scrape_items
image_name: ghcr.io/flexicon/tft-suggester/worker

trigger_webhook:
runs-on: ubuntu-latest
Expand All @@ -71,17 +38,3 @@ jobs:
- name: curl
run: |
curl -X POST ${{ secrets.DATA_FETCHED_WEBHOOK }}
cleanup:
runs-on: ubuntu-latest
needs:
- scrape_champions
- scrape_comps
- scrape_items
steps:
- uses: actions/delete-package-versions@0635864898b476b1b4ba530fc7854286f20b360c
with:
package-name: 'tft-suggester/worker'
package-type: 'container'
min-versions-to-keep: 5
delete-only-untagged-versions: 'true'

0 comments on commit 6020ae7

Please sign in to comment.