diff --git a/README.md b/README.md index 63a4012..ee98436 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://storageapi.fleek.co/fleek-team-bucket/Blog%20Inline/ic-action.png) -# Deploy Action +# IC Deploy Action [![Fleek](https://img.shields.io/badge/Made%20by-Fleek-blue)](https://fleek.co/) [![Dev Slack](https://img.shields.io/badge/Dev%20Slack-Channel-blue)](https://slack.fleek.co/) [![License](https://img.shields.io/badge/License-MIT-green)](https://github.com/FleekHQ/space-sdk/blob/master/LICENSE) @@ -8,7 +8,10 @@ ## Introduction -Fleek's Deploy Action provides an easy way to deploy your configured Fleek site's publish directory. +Fleek's IC deploy action wraps commands from the [dfx](https://github.com/dfinity/docs) command line tool, which deploys canister to the [Internet Computer](https://dfinity.org/). + + +The Github Action will trigger a new deployment to the Internet Computer when commits are pushed. ## Example Usage @@ -20,45 +23,78 @@ on: [push] jobs: test-deploy: runs-on: ubuntu-latest - name: A job to test the action-deploy action by deploying a test site + name: A job to deploy canisters to the IC steps: - uses: actions/checkout@v2 - - name: Deploy test site + - name: Install dependencies + run: npm install + - name: Deploy canisters id: deploy - uses: fleekhq/action-deploy@v1 + uses: ./ with: - apiKey: ${{ secrets.FLEEK_API_KEY }} - - name: Get the output url - run: echo "Deploy url is ${{ steps.deploy.outputs.deployUrl }}" + identity: ${{ secrets.DFX_IDENTITY }} + wallets: ${{ secrets.DFX_WALLETS }} + - name: Show success message + run: echo success! +``` + +## Initial Setup +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. + +``` + 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. -## Configuration Options +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. -The action can be configured with the following input arguments: +## Github Secrets +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. -- apiKey (required) - Your Fleek scoped API key that has permission to deploy to the configured site. +### DFX_IDENTITY +We have to export the content of your `default` identity and modify it so that it fits in a single line. -- workDir (optional) - The location of your .fleek.json config file. Defaults to repositories base directory. +First, locate your identity. For the `default` identity on Linux, it can be found in the following location `~/.config/dfx/identity/default/identity.pem`. -- commitHash - (optional) - Optional git commit hash to deploy. Only useful for fleek sites linked to github. +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 +``` + +### DFX_WALLETS +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. ## Contributing +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: 1. Fork this repository. 2. Make desired changes. -3. Confirm a successful Docker build with `docker build -t fleekhq/action-deploy .`. -4. [Open a Pull Request and follow the prompts](https://github.com/fleekhq/action-deploy/compare). +3. Confirm a successful Docker build with `docker build -t fleekhq/IC-Deploy-Action .`. +4. [Open a Pull Request and follow the prompts](https://github.com/fleekhq/IC-Deploy-Action/compare). We value and appreciate all contributions. -## Related Resources - -- [Fleek CLI](https://github.com/fleekhq/fleek-cli) -- [Fleek](https://fleek.co) - ## License -Fleeks Deploy Action is licensed under a [GNU General Public License](LICENSE) +Fleeks IC Deploy Action is licensed under a [GNU General Public License](LICENSE)