Integration with CI/CD Tools
This tutorial explains how to integrate the Walrus CLI with your CI/CD tools to achieve an automated deployment process.
Prerequisites
To follow this tutorial, you will need:
- A GitHub Repository.
- Installation of Walrus.
Creating an API Key
To allow the Walrus CLI to interact with the Walrus server, you first need to generate an API key:
- Navigate to
User Information
, selectAPI Keys
, then clickNew Key
. Provide a name for the key and set an expiration period. - After creation, copy the API key for later use.
Integrating Walrus CLI with CI/CD Tools
For this tutorial, we will demonstrate integration using GitHub Actions.
- In your GitHub repository, create a new file named
ci.yaml
within the.github/workflows
directory. This file will define your CI/CD workflow. - Configure the workflow to use GitHub Actions secrets, such as
CI_WALRUS_SERVER
andCI_WALRUS_API_KEY
, for securely handling sensitive data. Ensure theCI_WALRUS_SERVER
secret follows the formathttps://host:port
.
Below is a sample ci.yaml
for reference:
name: ci
on:
push:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch:
- amd64
steps:
- name: Download CLI
run: |
# Install walrus cli
curl -v -k -o walrus -LO "${{ secrets.CI_WALRUS_SERVER }}/cli?arch=amd64&os=linux"
chmod +x ./walrus
- name: Deploy
run: |
# Configure the CLI
./walrus login --server ${{ secrets.CI_WALRUS_SERVER }} --project web --environment dev --api-key ${{ secrets.CI_WALRUS_API_KEY }}
# Deploy resources using Walrus files.
./walrus apply -f walrus-file.yaml --wait
After successful deployment, you can view the deployed services in the Walrus dashboard. For additional CLI commands and usage, please refer to the CLI documentation.