From 9ef98193d6163421510937fc3819a76e569b3318 Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Sun, 29 Mar 2026 18:25:29 +0200 Subject: [PATCH] Added RSS --- jenkins/324JenkinsfileRSS | 53 ++++++++++++++++++++++++++++ workflows/324.yml | 72 +++++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 jenkins/324JenkinsfileRSS diff --git a/jenkins/324JenkinsfileRSS b/jenkins/324JenkinsfileRSS new file mode 100644 index 0000000..ff9608a --- /dev/null +++ b/jenkins/324JenkinsfileRSS @@ -0,0 +1,53 @@ +pipeline { + agent any + + triggers { + // 'H' balances the load on Jenkins, running roughly every 30 minutes + cron('H/30 * * * *') + } + + stages { + stage('Checkout Code') { + steps { + checkout scm + } + } + + stage('Setup Python & Install Dependencies') { + steps { + sh ''' + # Create a virtual environment named 'venv' + python3 -m venv venv + + # Activate it and install the required packages + . venv/bin/activate + pip install -U atproto fastfeedparser beautifulsoup4 httpx arrow charset-normalizer + ''' + } + } + + stage('Run Script') { + steps { + // Securely inject Jenkins credentials as environment variables + withCredentials([ + string(credentialsId: 'BSKY_324_HANDLE', variable: 'BSKY_324_HANDLE'), + string(credentialsId: 'BSKY_324_USERNAME', variable: 'BSKY_324_USERNAME'), + string(credentialsId: 'BSKY_324_APP_PASSWORD', variable: 'BSKY_324_APP_PASSWORD') + ]) { + sh ''' + # Activate the exact same virtual environment so Python finds the packages + . venv/bin/activate + + # Run the script with the RSS URL, credentials, and custom service flag + python3 rss2bsky.py \ + "https://api.3cat.cat/noticies?_format=rss&origen=frontal&frontal=n324-portada-noticia&version=2.0" \ + "$BSKY_324_HANDLE" \ + "$BSKY_324_USERNAME" \ + "$BSKY_324_APP_PASSWORD" \ + --service "https://eurosky.social" + ''' + } + } + } + } +} diff --git a/workflows/324.yml b/workflows/324.yml index 00d5d10..ff9608a 100644 --- a/workflows/324.yml +++ b/workflows/324.yml @@ -1,23 +1,53 @@ -name: 3CatInfo RSS to BSKY -description: "A GitHub Action to post 324 (now 3CatInfo) RSS feed items to Bluesky (BSKY) using a Python script." +pipeline { + agent any + + triggers { + // 'H' balances the load on Jenkins, running roughly every 30 minutes + cron('H/30 * * * *') + } -on: - workflow_dispatch: - schedule: - - cron: '*/30 * * * *' # every 30 minutes + stages { + stage('Checkout Code') { + steps { + checkout scm + } + } -jobs: - post: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.14' - - name: Install dependencies - run: | - pip install atproto fastfeedparser beautifulsoup4 httpx arrow charset-normalizer - - name: Run script - run: | - python3 rss2bsky.py https://api.3cat.cat/noticies\?_format\=rss\&origen\=frontal\&frontal\=n324-portada-noticia\&version\=2.0 ${{ secrets.BSKY_324_HANDLE }} ${{ secrets.BSKY_324_USERNAME }} ${{ secrets.BSKY_324_APP_PASSWORD }} --service "https://eurosky.social" + stage('Setup Python & Install Dependencies') { + steps { + sh ''' + # Create a virtual environment named 'venv' + python3 -m venv venv + + # Activate it and install the required packages + . venv/bin/activate + pip install -U atproto fastfeedparser beautifulsoup4 httpx arrow charset-normalizer + ''' + } + } + + stage('Run Script') { + steps { + // Securely inject Jenkins credentials as environment variables + withCredentials([ + string(credentialsId: 'BSKY_324_HANDLE', variable: 'BSKY_324_HANDLE'), + string(credentialsId: 'BSKY_324_USERNAME', variable: 'BSKY_324_USERNAME'), + string(credentialsId: 'BSKY_324_APP_PASSWORD', variable: 'BSKY_324_APP_PASSWORD') + ]) { + sh ''' + # Activate the exact same virtual environment so Python finds the packages + . venv/bin/activate + + # Run the script with the RSS URL, credentials, and custom service flag + python3 rss2bsky.py \ + "https://api.3cat.cat/noticies?_format=rss&origen=frontal&frontal=n324-portada-noticia&version=2.0" \ + "$BSKY_324_HANDLE" \ + "$BSKY_324_USERNAME" \ + "$BSKY_324_APP_PASSWORD" \ + --service "https://eurosky.social" + ''' + } + } + } + } +}