From 76dc4bd24892ac3761c86947407222cc037e7bb8 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 8 Jul 2024 23:27:10 +0000 Subject: [PATCH] Add workflow to refresh trakt oauth token --- .github/workflows/trakt.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/trakt.yml diff --git a/.github/workflows/trakt.yml b/.github/workflows/trakt.yml new file mode 100644 index 0000000..691a46d --- /dev/null +++ b/.github/workflows/trakt.yml @@ -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 }}