Files
Jackett-Jackett/.github/workflows/definitions-update.yml

69 lines
2.3 KiB
YAML

name: Update definitions
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
pull_request:
paths:
- '.github/workflows/definitions-update.ya?ml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
jobs:
update-rudub:
name: Update rudub
if: github.repository == 'Jackett/Jackett'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate Token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Checkout
uses: actions/checkout@v5
with:
token: ${{ steps.app-token.outputs.token }}
- name: Setup Environment Variables
run: |
echo "CURRENT_RUDUB_DOMAIN=$(date +'%b%d' | tr '[:upper:]' '[:lower:]').rudub.bet" >> $GITHUB_ENV
echo "PREVIOUS_RUDUB_DOMAIN=$(date --date='yesterday' +'%b%d' | tr '[:upper:]' '[:lower:]').rudub.bet" >> $GITHUB_ENV
- name: Update rudub definition
uses: mikefarah/yq@master
with:
cmd: yq -i '.legacylinks += "https://" + strenv(PREVIOUS_RUDUB_DOMAIN) + "/" | .legacylinks += "http://" + strenv(CURRENT_RUDUB_DOMAIN) + "/" | .links = ["https://" + strenv(CURRENT_RUDUB_DOMAIN) + "/"] | .legacylinks |= unique | .legacylinks = .legacylinks.[-30:]' src/Jackett.Common/Definitions/rudub.yml
- name: Show changes
run: git diff --color
- name: Commit Changes
if: github.event_name != 'pull_request'
run: |
git config user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
git add src/Jackett.Common/Definitions/rudub.yml
if git status | grep -q modified
then
git commit -m "Update rudub"
git push
else
echo "No changes since last run"
fi