Skip to content

PIB_India_Ministry

PIB_India_Ministry #18

Workflow file for this run

name: PIB_India_Ministry
on:
workflow_dispatch:
inputs:
desc:
description: 'Enter the appropriate data in the following sections'
default: 'DO NOT EDIT THIS LEAVE THIS AS IS'
intialDate:
description: 'Intial Date in yyyy-mm-dd format'
required: true
type: string
lastDate:
description: 'Last Date in yyyy-mm-dd format'
required: true
type: string
customTag:
description: 'make a custom tag for zip in format. Do not put special character or spaces. eg PIB_India_FinMin and so on'
required: true
default: 'PIB_Custom_Tag'
type: string
ministrycode:
description: 'Enter the ministry code
(Find the ministry code from ministries.txt file)'
required: true
default: 0
type: choice
options:
- 0
- 1
- 2
- 3
- 61
- 62
- 63
- 68
- 70
- 71
- 75
- 80
- 72
- 14
- 45
- 56
- 35
- 1330
- 27
- 58
- 41
- 26
- 42
- 16
- 24
- 60
- 39
- 1440
- 66
- 17
- 33
- 57
- 48
- 73
- 67
- 8
- 1323
- 30
- 4
- 15
- 1340
- 40
- 31
- 53
- 5
- 47
- 11
- 1336
- 21
- 7
- 51
- 44
- 65
- 28
- 59
- 10
- 12
- 6
- 20
- 79
- 52
- 23
- 69
- 43
- 13
- 46
- 77
- 50
- 55
- 18
- 25
- 19
- 36
- 49
- 32
- 38
- 64
- 9
- 78
- 1325
- 74
- 34
- 37
- 1005
- 1406
- 1454
- 1458
- 1470
- 1484
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/{text,monthly,daily}
sudo pip install -U pyopenssl cryptography
- name: set env
run: |
echo ${{ inputs.customTag }}
echo PIB_TAG=${{ inputs.customTag }} >> $GITHUB_ENV
- name: run script
run: |
source .env
dwngrd_chrome
pib_min ${{ inputs.intialDate }} ${{ inputs.lastDate }} ${{ inputs.ministrycode }} || err_handle "10" "Spider failed to run"
- name: make txt files
run: |
source .env
pdftxt
- name: zipup_months_articles
run: |
source .env
cd /home/runner/
zip -r "/home/runner/zips/monthly/PIB_${{ env.PIB_TAG }}.zip" pib || err_handle "13" "Failed to create PIB_${{ env.PIB_TAG }}.zip"
- name: zipup_months_articles_by_days
run: |
source .env
cd /home/runner
for day in pib/*/*/*; do
echo $day
dayname=$(basename $day)
monthdir=$(dirname $day)
monthname=$(basename $monthdir)
yeardir=$(dirname $monthdir)
yearname=$(basename $yeardir)
zip -r "/home/runner/zips/daily/PIB_${dayname}_${monthname}_${yearname}_${{ env.PIB_TAG }}.zip" $day || err_handle "13" "Failed to create PIB_${dayname}_${{ env.PIB_TAG }}.zip"
done
- name: Create Monthly zip
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/zips/monthly/*.zip"
token: ${{ secrets.PIB }}
tag: "PIB_All_${{ env.PIB_TAG }}"
allowUpdates: true
body : "PIB articles from ${{ inputs.intialDate }} to ${{ inputs.lastDate }}"
- name: Create Daily zips
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/zips/daily/*.zip"
token: ${{ secrets.PIB }}
tag: "PIB_Daily_${{ env.PIB_TAG }}"
allowUpdates: true
body : "PIB articles (by date) from ${{ inputs.intialDate }} to ${{ inputs.lastDate }}"
- name: Create Link text files
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/piblinks/*.txt"
token: ${{ secrets.PIB }}
tag: "PIB_Links_${{ env.PIB_TAG }}"
allowUpdates: true
body : "PIB articles links from ${{ inputs.intialDate }} to ${{ inputs.lastDate }}"