This guide will help you set up a continuous deployment (CD) pipeline for deploying your project to the Internet Computer using GitHub Actions. The pipeline is defined in a file named cd.yml.
- You need to have a GitHub account and a repository where your project is stored.
- You need to have the DFINITY Canister SDK (
dfx) installed on your machine. If you don't have it installed, you can download it from the DFINITY SDK documentation page.
-
Create a GitHub Actions Workflow
In your GitHub repository, create a new file under
.github/workflows/namedcd.ymland paste the provided code into it. -
Add a Secret Token in GitHub
The
cd.ymlfile references a secret namedDFX_IDENTITY. This secret should contain your exported identity file in base64 format.To add this secret:
- Go to your GitHub repository and click on
Settings. - Click on
Secretsin the left sidebar. - Click on
New repository secret. - Enter
DFX_IDENTITYas the name. - For the value, you need to provide your exported identity file in base64 format. Follow the next step to create this.
- Go to your GitHub repository and click on
-
Export and Encode Your Identity
You can export your identity using the
dfxcommand-line tool with the following command:dfx identity export identityname > exported_identity.pem
Replace
identitynamewith the name of your identity. Be careful with storing this file as it is not protected with your password.To convert this file into base64 format, you can use the
base64command:base64 exported_identity.pem
This will output a base64-encoded string. Copy this string and paste it as the value for the
DFX_IDENTITYsecret in GitHub. -
Push to Master
Once you have set up the
cd.ymlfile and added theDFX_IDENTITYsecret, you can trigger the CD pipeline by pushing to themasterbranch of your repository. The pipeline will automatically deploy your project to the Internet Computer.