Manual Update Tosho #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Manual Update | |
on: | |
workflow_dispatch: | |
inputs: | |
feed_name: | |
description: 'Name of the feed to update' | |
required: true | |
type: choice | |
options: | |
- Ember | |
- Nandesuka | |
- Nandesuka2 | |
- Erai-HEVC | |
start_page: | |
description: 'Starting page number' | |
required: true | |
type: integer | |
default: 1 | |
end_page: | |
description: 'Ending page number' | |
required: true | |
type: integer | |
default: 1 | |
jobs: | |
update-rss: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install requests pytz | |
- name: Determine Feed Number and API Link | |
id: set-feed-details | |
run: | | |
echo "FEED_NAME=${{ github.event.inputs.feed_name }}" >> $GITHUB_ENV | |
if [ "${{ github.event.inputs.feed_name }}" == "Ember" ]; then | |
echo "FEED_NUMBER=1" >> $GITHUB_ENV | |
elif [ "${{ github.event.inputs.feed_name }}" == "Nandesuka" ]; then | |
echo "FEED_NUMBER=2" >> $GITHUB_ENV | |
elif [ "${{ github.event.inputs.feed_name }}" == "Nandesuka2" ]; then | |
echo "FEED_NUMBER=3" >> $GITHUB_ENV | |
elif [ "${{ github.event.inputs.feed_name }}" == "Erai-HEVC" ]; then | |
echo "FEED_NUMBER=4" >> $GITHUB_ENV | |
else | |
echo "Unknown feed name" | |
exit 1 | |
fi | |
echo "START_PAGE=${{ github.event.inputs.start_page }}" >> $GITHUB_ENV | |
echo "END_PAGE=${{ github.event.inputs.end_page }}" >> $GITHUB_ENV | |
- name: Run update script | |
run: python rssfeed.py ${{ env.FEED_NUMBER }} ${{ env.START_PAGE }} ${{ env.END_PAGE }} | |
- name: Commit and push changes | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
git add rssfeed/*.xml | |
git commit -m "Update RSS feed" || echo "No changes to commit" | |
git pull origin main --rebase | |
git push https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git |