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 namedcognition-github-actions.yml
.
4. Crafting the Workflow File
Now, copy and paste the following YAML content into the
cognition-github-actions.yml
file:
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.
Frequently Asked Question:
How does Cognition determine the location of the JavaScript code?
Cognition will look for an index.html file. If this file exists, Cognition will use the JavaScript code inside the file. However, if there is an index.js file present, the index.html will be ignored, and the content of the index.js file will be saved as the source code. Any other .js files will be stored and served as external libraries.
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