Skip to content

PIB_India_Daily

PIB_India_Daily #15195

Workflow file for this run

name: PIB_India_Daily
on:
schedule:
- cron: '0 */1 * * *'
workflow_dispatch:
jobs:
pib_articles:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setting_up
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
sudo apt update
sudo apt install --fix-missing -y python3 wkhtmltopdf fd-find poppler-utils
sudo ln -s $(which fdfind) /usr/bin/fd
sudo pip install -r requirements.txt
mkdir -p /home/runner/{zips,pib,pib_text,piblinks}
mkdir -p /home/runner/zips/{text,daily,monthly}
sudo pip install -U pyopenssl cryptography
- name: set env
run: |
echo ${{ github.ref_name }}
echo "PIB_MONTH=$(date +'%b')" >> $GITHUB_ENV
echo "PIB_YEAR=$(date +'%Y')" >> $GITHUB_ENV
- name: download and unzip previous articles
run: |
source .env
cd /home/runner
wget -q -c "https://github.com/nit-in/pib/releases/download/PIB_Monthly_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}/PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" || err_handle "11" "Error downloading PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
unzip "PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" -d /home/runner/pib/${{ env.PIB_YEAR }} || err_handle "12" "Failed to unzip PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
wget -q -c "https://github.com/nit-in/pib/releases/download/PIB_Text_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}/PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" || err_handle "11" "Error downloading PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
unzip "PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" -d /home/runner/pib_text/${{ env.PIB_YEAR }} || err_handle "13" "Failed to unzip PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
tday=$(date +"%d_%b_%Y")
lnkfile="PIB_LINKS_${tday}.txt"
wget -q -c "https://github.com/nit-in/pib/releases/download/PIB_Links_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}/${lnkfile}" || err_handle "14" "Failed to download PIB_Links_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}/${lnkfile}"
mv ${lnkfile} /home/runner/piblinks/${lnkfile} || err_handle "16" "Failed to copy ${lnkfile}"
- name: run script
run: |
source .env
pib_today || err_handle "10" "PIB_TODAY running failed"
pib_last_day || err_handle "10" "PIB_LAST_DAY running failed"
- name: make txt files
run: |
source .env
pdftxt
- name: zipup_months_articles
run: |
source .env
cd /home/runner/pib/${{ env.PIB_YEAR }}
zip -r "/home/runner/zips/monthly/PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" ${{ env.PIB_MONTH }} || err_handle "12" "Failed to zip PIB_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
- name: zipup_months_articles_by_days
run: |
source .env
cd /home/runner
for day in pib/${{ env.PIB_YEAR }}/${{ env.PIB_MONTH }}/*; do
echo $day
dayname=$(basename $day)
zip -r "/home/runner/zips/daily/PIB_${dayname}_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" $day || err_handle "12" "Failed to zip PIB_${dayname}_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
done
- name: zipup_text
run: |
source .env
cd /home/runner/pib_text/${{ env.PIB_YEAR }}
zip -r "/home/runner/zips/text/PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip" ${{ env.PIB_MONTH }} || err_handle "12" "Failed to zip PIB_TEXT_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}.zip"
- name: Create Monthly zip
uses: ncipollo/release-action@v1.14.0
with:
artifacts: "/home/runner/zips/monthly/*.zip"
token: ${{ secrets.PIB }}
tag: "PIB_Monthly_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}"
allowUpdates: true
body : "PIB articles for the month of ${{ env.PIB_MONTH }}, ${{ env.PIB_YEAR }}"
- name: Create Daily zips
uses: ncipollo/release-action@v1.14.0
with:
artifacts: "/home/runner/zips/daily/*.zip"
token: ${{ secrets.PIB }}
tag: "PIB_Daily_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}"
allowUpdates: true
body : "PIB articles (by date) for the month of ${{ env.PIB_MONTH }}, ${{ env.PIB_YEAR }}"
- name: Create text zips
uses: ncipollo/release-action@v1.14.0
with:
artifacts: "/home/runner/zips/text/*.zip"
token: ${{ secrets.PIB }}
tag: "PIB_Text_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}"
allowUpdates: true
body : "PIB articles text for the month of ${{ env.PIB_MONTH }}, ${{ env.PIB_YEAR }}"
- name: Create Link text files
uses: ncipollo/release-action@v1.14.0
with:
artifacts: "/home/runner/piblinks/*.txt"
token: ${{ secrets.PIB }}
tag: "PIB_Links_${{ env.PIB_MONTH }}_${{ env.PIB_YEAR }}"
allowUpdates: true
body : "PIB articles links for the month of ${{ env.PIB_MONTH }}, ${{ env.PIB_YEAR }}"