GitHub Action
Fleek IC Action
Fleek's IC deploy action wraps commands from the dfx command line tool, which deploys canister to the Internet Computer.
The Github Action will trigger a new deployment to the Internet Computer when commits are pushed.
Create a .github/workflows/deploy.yml
workflow file in your repository with the following configuration:
on: [push]
jobs:
test-deploy:
runs-on: ubuntu-latest
name: A job to deploy canisters to the IC
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Deploy canisters
id: deploy
uses: fleekhq/ic-deploy-action@v1
with:
identity: ${{ secrets.DFX_IDENTITY }}
wallets: ${{ secrets.DFX_WALLETS }}
- name: Show success message
run: echo success!
Before including the Github Action to your CI/CD pipeline, you need a project configured and deployed to the IC.
If it's not already done, create a new project with the dfx
CLI.
dfx new hello-world
Then, you can make an initial deployment to the IC after having installed dependencies with npm install
if necessary.
dfx deploy --network=ic
The canisters are now deployed. At this point, a canister_ids.json
file will have been created in your repository. It's important to push this file to github, because it identifies your Canister on the IC.
Furthermore, these canisters have been deployed with a particular identity, which you by default is called default
. We will have to export the private key associated with that identity through a Github secret.
As seen in the code snippets in the previous section, the Github Action necessitates the addition of two secrets in order to make additional deployments through the same identity.
We have to export the content of your default
identity and modify it so that it fits in a single line.
First, locate your identity. For the default
identity on Linux, it can be found in the following location ~/.config/dfx/identity/default/identity.pem
.
Run the command below and copy the output to the DFX_IDENTITY
Github Secret. The command below can be modified if the path to the identity.pem
file differs.
awk 'NF {sub(/\r/, ""); printf "%s\\r\\n",$0;}' ~/.config/dfx/identity/default/identity.pem
Copy the contents of the wallets.json
file that in the same directory as the identity.pem
file and paste it to the DFX_WALLETS
Github secret. The content of the file can be retrieved by the code below.
cat ~/.config/dfx/identity/default/wallets.json
Note that this file will not be present if you have not initially deployed the canisters.
By default, the action will deploy with the command dfx deploy --network=ic
, but the value of ic
can be overriden through the network
input.
on: [push]
jobs:
test-deploy:
runs-on: ubuntu-latest
name: A job to deploy canisters to the IC
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Deploy canisters
id: deploy
uses: fleekhq/ic-deploy-action@v1
with:
identity: ${{ secrets.DFX_IDENTITY }}
wallets: ${{ secrets.DFX_WALLETS }}
network: alpha
- name: Show success message
run: echo success!
There are a lot of variations of Canister deployments possible, such as not using the default identity and wallet, different working directories, deployments that flushes the memory in the canisters and some that don't, etc...
Any contributions that offer more flexibility and options are very valuable!
To submit a feature, bug fix, or enhancement to Deploy Actions, follow these steps:
- Fork this repository.
- Make desired changes.
- Confirm a successful Docker build with
docker build -t fleekhq/IC-Deploy-Action .
. - Open a Pull Request and follow the prompts.
We value and appreciate all contributions.
Fleeks IC Deploy Action is licensed under a GNU General Public License