GitHub integration

Using GitHub to manage your experiment's code can be immensely beneficial, providing version control, collaboration features, and much more. With Cognition's GitHub integration, you can seamlessly deploy your JsPsych experiments directly from your repository. Here's how you can set it up:

1. Generate a Personal Access Token

  • Start by creating a new Personal Access Token on GitHub. This token will authenticate your requests.

  • Once generated, make sure to copy this secret token for future use.

2. Add the Token to Repository Secrets

  • Navigate to the main page of your repository on GitHub.

  • Click on "Settings" right under your repository name.

  • In the sidebar, under the "Security" section, select "Secrets" followed by "Actions".

  • Click on "New repository secret".

  • For the name, input PERSONAL_ACCESS_TOKEN.

  • Paste the previously copied secret token in the value field.

  • Finally, click "Add secret" to save it.

3. Setting up the Workflow Directory

  • Check if your repository has a .github/workflows directory. If not, create one.

  • Inside the .github/workflows directory, create a file named cognition-github-actions.yml.

4. Crafting the Workflow File

  • Now, copy and paste the following YAML content into the cognition-github-actions.yml file:

on: [push]

    runs-on: ubuntu-latest
    name: Deploy experiment to Cognition
      - uses: actions/checkout@v3
      - uses: javidalpe/cognition-deploy-action@v1.1.2
        id: deploy
          personal-access-token: ${{secrets.PERSONAL_ACCESS_TOKEN}}
      - run: echo "The public link to the task is ${{ }}"

5. Triggering the Workflow

  • Once you've added and committed the workflow file to your repository, every subsequent push to the repository will trigger this workflow.

  • When triggered, this workflow will automatically deploy your experiment to Cognition.

6. Deployment Confirmation

  • After each deployment, the workflow will output the public link to the deployed task in the GitHub Actions logs. You can use this link to directly access and share your task.

In conclusion, Cognition's GitHub integration offers a smooth and efficient way to manage and deploy your JsPsych experiments. This streamlined approach ensures that the latest version of your experiment is always available on Cognition, facilitating continuous development and deployment.

Last updated