Octopus Deploy Documentation

GitHub Actions

Last updated

GitHub is a popular git-based source-control platform.

GitHub Actions is GitHub's cloud-based continuous integration server.

The GitHub-hosted runners require your Octopus Server to be accessible over the Internet. Otherwise you must self-host your runners.

Integrating with GitHub Actions

Octopus Deploy has a custom GitHub Action, Install Octopus CLI.

The GitHub Action install-octopus-cli-action installs the Octopus CLI on any operating system, including:

  • Windows
  • MacOS
  • Linux
  • Self-Hosted Runners

Once the Octopus CLI is installed, you can perform any action that you would on the terminal using the CLI.

GitHub Actions secrets

You can use encrypted secrets in your workflow (available from the Settings ➜ Secrets menu of your GitHub repository), which is a great place to store sensitive information such as your Octopus Deploy API keys (which is not something you should store in your source control).

For example:

Variable name Description
OCTOPUS_SERVER The Octopus Server URL you wish to push the final package to
OCTOPUS_APIKEY The Octopus Deploy API Key required for authentication

GitHub Actions configuration

When you create your first GitHub Action for your repository, GitHub stores the actions as workflows in the .github/workflows folder in your repository. You need to modify those files to run the build, pack, and/or push package commands.

Example workflows

Here's a few example workflows for Linux, MacOS, and Windows to list deployments from an Octopus Deploy instance.

GitHub Actions includes a number of default environment variables. These examples use those plus encrypted secrets from above.

name: listdeployments

env:
  serverURL: your_server_name

on:
   push:
     branches: [ main ]
   pull_request:
     branches: [ main ]

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      
      - name: Install Octopus CLI
        uses: OctopusDeploy/install-octopus-cli-action@v1.1.1
        with:
          version: latest
          
      - name: list-octopusdeploy-deployments
        run: octo list-deployments --server=${{ env.serverURL }} --apiKey=${{ secrets.apiKey }}
name: listdeployments

env:
  serverURL: your_server_name

on:
   push:
     branches: [ main ]
   pull_request:
     branches: [ main ]

jobs:

  build:
    name: Build
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      
      - name: Install Octopus CLI
        uses: OctopusDeploy/install-octopus-cli-action@v1.1.1
        with:
          version: latest
          
      - name: list-octopusdeploy-deployments
        run: octo list-deployments --server=${{ env.serverURL }} --apiKey=${{ secrets.apiKey }}
name: listdeployments

env:
  serverURL: your_server_name

on:
   push:
     branches: [ main ]
   pull_request:
     branches: [ main ]

jobs:

  build:
    name: Build
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v2
      
      - name: Install Octopus CLI
        uses: OctopusDeploy/install-octopus-cli-action@v1.1.1
        with:
          version: latest
          
      - name: list-octopusdeploy-deployments
        run: octo list-deployments --server=${{ env.serverURL }} --apiKey=${{ secrets.apiKey }}

Example GitHub Actions Repo:

View a working GitHub Actions example on our samples GitHub repository.

See the corresponding Octopus project on our samples instance.

Need support? We're here to help.