Skip to content

Commit

Permalink
Add workflow to refresh trakt oauth token
Browse files Browse the repository at this point in the history
  • Loading branch information
josh authored Jul 8, 2024
1 parent 22fec99 commit 76dc4bd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/trakt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Trakt

on:
schedule:
- cron: "0 0 1 * *"
workflow_dispatch:

jobs:
refresh:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Refresh Trakt token
run: |
curl --silent --fail \
-X POST \
-F "client_id=$TRAKT_CLIENT_ID" \
-F "client_secret=$TRAKT_CLIENT_SECRET" \
-F "refresh_token=$TRAKT_REFRESH_TOKEN" \
-F "grant_type=refresh_token" \
'https://api.trakt.tv/oauth/token' >token.json
env:
TRAKT_CLIENT_ID: ${{ secrets.TRAKT_CLIENT_ID }}
TRAKT_CLIENT_SECRET: ${{ secrets.TRAKT_CLIENT_SECRET }}
TRAKT_REFRESH_TOKEN: ${{ secrets.TRAKT_REFRESH_TOKEN }}

- name: Update GitHub secrets
run: |
jq --raw-output '.access_token' token.json | gh secret set --app actions TRAKT_ACCESS_TOKEN
jq --raw-output '.access_token' token.json | gh secret set --app codespaces TRAKT_ACCESS_TOKEN
jq --raw-output '.refresh_token' token.json | gh secret set --app actions TRAKT_REFRESH_TOKEN
jq --raw-output '.refresh_token' token.json | gh secret set --app codespaces TRAKT_REFRESH_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

0 comments on commit 76dc4bd

Please sign in to comment.