Modified auth mechanism. Test 1 #180
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
# This is a basic workflow to help you get started with Actions | |
name: Publish on ankiweb.net | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
- name: Archive all repo for sending | |
run: | | |
zip -r $GITHUB_WORKSPACE/$GITHUB_SHA.zip . -x '*.git*' '.github', | |
ls -d -1 "$PWD/"**/ | |
ls -l | |
# - name: Get csrf token from Anki | |
# id: authRequest | |
# uses: fjogeleit/http-request-action@master | |
# with: | |
# url: 'https://ankiweb.net/account/login' | |
# method: 'GET' | |
# - name: Retrieve CSRF token | |
# run: echo ${{ steps.authRequest.outputs.response }} | grep -oP 'csrf_token" value="\K([^"]+)' > token.txt | |
- name: Authenticate with Anki | |
env: | |
ANKI_LOGIN: ${{ secrets.ANKILOGI_N }} | |
ANKI_PASSWORD: ${{ secrets.ANKIPASSWORD }} | |
run: | | |
CSRF=$(cat token.txt) | |
curl -d $'\n\u0010'$ANKI_LOGIN$'\u0012\u000'$ANKI_PASSWORD https://ankiweb.net/svc/account/login -c $GITHUB_WORKSPACE/cookie -b 'ankiweb=login' > null | |
echo "ANKI_COOKIE="$(cat $GITHUB_WORKSPACE/cookie | grep -oP '^#HttpOnly_ankiweb.net.+ankiweb\s+\K.+$') >> $GITHUB_ENV | |
- name: Upload to anki | |
run: > | |
curl | |
-F 'title=Cambridge Dictionary' | |
-F 'tags=cambridge, addon, word lists' | |
-F 'supportURL=https://github.com/am-silex/anki_cambridge' | |
-F 'minVer0=0' | |
-F 'maxVer0=0' | |
-F "desc=Anki Add-on for downloading words definitions and associating resources (pronunciation, images, etc) from Cambridge Dictionary website. What it's done (so far): Creating notes from link to a word (word title, definition, grammar, IPA, sound, meanings, examples) Fetching words from your word lists (with deleting words after successful fetching). Anyone willing to improve my idea and contribute is welcome on addon's GitHub: https://github.com/am-silex/anki_cambridge" | |
-F 'id=1875288089' | |
-F 'submit=Update' | |
-F 'v21file0=@${{ github.workspace }}/${{ github.sha }}.zip' | |
-b 'ankiweb=${{ env.ANKI_COOKIE }}' | |
-v | |
https://ankiweb.net/shared/upload | |