Getting started
Deploying your software with NanoAPI
You can have your first application up and running on NanoAPI in under 10 minutes. Follow the steps below to see how easy it is to get your software configured, built, and deployed.
What you’ll need:
Before you start, please check you have the following:
- GitHub or GitLab Account:
- A valid GitHub or GitLab account is required for signing up and granting access permissions to NanoAPI.
- Repository to Deploy:
- A repository on GitHub or GitLab that you want to deploy using NanoAPI.
- Login Credentials:
- Your GitHub or GitLab username/email and password for authentication during the signup and approval process.
Step 1: Sign Up to NanoAPI (2 min.)
What you’ll need:
- GitHub or GitLab Account.
- Login Credentials.
- Go to app.nanoapi.io/signup
- Choose a Signup Method:
- You will be presented with options to sign up using different methods. Choose either:
- GitHub Account: Click on the "Sign up with GitHub" button.
- GitLab Account: Click on the "Sign up with GitLab" button.
- You will be presented with options to sign up using different methods. Choose either:
- Authenticate with Your Chosen Account:
- If you selected GitHub:
- You will be redirected to GitHub’s login page. Enter your GitHub credentials (username/email and password) and click "Sign in."
- If you selected GitLab:
- You will be redirected to GitLab’s login page. Enter your GitLab credentials (username/email and password) and click "Sign in."
- If you selected GitHub:
- Grant and Authorize NanoAPI:
- After logging in, you are asked to authorize NanoAPI to access your GitHub or GitLab account. Click “Grant” to grant acces to your organisations and then review the permissions and click "Authorize" to proceed.
Step 2: Search for a Repository (1 min.)
What you’ll need:
- Repository to Deploy.
- Redirect to Dashboard:
- After approving access to your GitHub or GitLab account, you will be redirected to the NanoAPI dashboard.
- Search for a Repository:
- On the dashboard, locate the search bar.
- Enter the name of the repository you want to deploy or the owner’s name in the search bar. This will be mostly: “ownername/reponame”
- Locate the Repository:
- Browse through the search results to find the repository you are looking for. Refer to the provided image if needed:
Step 3: Build configuration (2 min.)
What you’ll need:
- Repository to Deploy.
Redirect to Build Config Screen:
- Click on the "View builds" button at your repository, you will see an option labeled "Create/View build configs." Click on this option.
- Build Config Screen:
- You will be taken to the build config screen.
- Create New Build Config:
- On the build config screen, locate the option to create a new build config.
- Click on the "Create New" button to start configuring your new service.
- Fill in Configuration Details:
- Provide the necessary details for your build configuration. This may include:
- Build Name: A unique name for your build configuration.
- Environment Variables: Any environment variables needed for your service.
- Build Commands: Commands to build your application.
- Deployment Settings: Settings specific to your deployment environment.
- Make sure to fill in all required fields accurately.
- Provide the necessary details for your build configuration. This may include:
- Save Configuration:
- Once you have entered all the necessary details, click on the "Save" button to save your build configuration.
Step 4: Create an API Token (1 min.)
What you’ll need:
- Repository to Deploy.
Navigate to the API Tokens Page:
- Go to the API Tokens page.
Create a New Token:
- Click on the "Create a new token" button.
- Enter a name for your token.
- The new token will appear in the upper right corner of the screen.
- Click on the token to copy it to your clipboard.
Secure Your Token in GitHub or GitLab:
- Keep the token safe, as it is used to authenticate your service with Nano API.
- Note that you can create multiple tokens and revoke them anytime.
- Add the API Token to Your Repository as a Secret Value:
- Navigate to your repository on GitHub or GitLab.
- Go to the "Settings" page.
- Add a New Secret:
- Find the "Secrets" or "Environment Variables" tab.
- Click on "New Secret" or "Add Secret."
- Name and Paste the Secret:
- Name your secret
NANO_API_TOKEN
(or another preferred name). - Paste the API token as the value for this secret.
- Name your secret
Step 5: Set Up Your CI/CD Pipeline (2 min.)
What you’ll need:
GitHub or GitLab Account.
Repository to Deploy.
Create a Workflow File:
- For GitHub: In your repository, navigate to
.github/workflows
. - For GitLab: In your repository, navigate to
.gitlab-ci.yml
. - Create a new file named
deploy_using_nano.yml
.
- For GitHub: In your repository, navigate to
Add Workflow Configuration:
Copy and paste the following content into
deploy_using_nano.yml
. This file should exist within the.github/workflows
or the root directory of your repository.Copy this into your new GitHub CI file:
# .github/workflows/deploy-nanoapi.ymlname: nanoapi_build_and_deployon: [push]jobs:ci:runs-on: ubuntu-lateststeps:- name: Build and deploy via Nano APIuses: Nano-API/Deploy@version/0with:apiKey: ${{ secrets.NANO_API_TOKEN }} # Your Nano API token, stored in Github secretsbuildConfigId: '<your_build_config_id>'commitSha: ${{ github.sha }}
Note: Replace
<your_build_config_id>
with the ID of the build configuration you created in Step 3.
Step 6: Push a New Commit (1 min.)
What you’ll need:
- GitHub or GitLab Account.
- Repository to Deploy.
- Make Changes:
- Make any necessary changes to your code or repository.
- Commit and Push:
- Commit your changes.
- Push the commit to your repository.
- Trigger the Workflow:
- The push will trigger the CI/CD pipeline.
- Monitor the build and deploy process in the Actions tab of your repository.
Wrap Up
You have successfully set up automatic builds and deployments for your service using Nano API in under 10 minutes. With this setup, every time you push a new commit, Nano API will automatically build and deploy your service, facilitating quick iterations and deployments.