Add Octopus Deploy release and deploy workflow (#2651)

* Create Octopus Deploy workflow template

* add properties file

* Pin step versions

* update some text

* add octopus icon

* added linebreak

Co-authored-by: Alexis Abril <alexisabril@github.com>

* added linebreak

Co-authored-by: Alexis Abril <alexisabril@github.com>

* update octopusdeploy icon name

---------

Co-authored-by: Alexis Abril <alexisabril@github.com>
This commit is contained in:
Rob E
2024-12-14 02:54:28 +10:00
committed by GitHub
parent dfc0cdc56b
commit f90b59f7cd
3 changed files with 130 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by separate terms of service,
# privacy policy, and support documentation.
#
# This workflow will build and publish a Docker container which is then deployed through Octopus Deploy.
#
# The build job in this workflow currently assumes that there is a Dockerfile that generates the relevant application image.
# If required, this job can be modified to generate whatever alternative build artifact is required for your deployment.
#
# This workflow assumes you have already created a Project in Octopus Deploy.
# For instructions see https://octopus.com/docs/projects/setting-up-projects
#
# To configure this workflow:
#
# 1. Decide where you are going to host your image.
# This template uses the GitHub Registry for simplicity but if required you can update the relevant DOCKER_REGISTRY variables below.
#
# 2. Create and configure an OIDC credential for a service account in Octopus.
# This allows for passwordless authentication to your Octopus instance through a trust relationship configured between Octopus, GitHub and your GitHub Repository.
# https://octopus.com/docs/octopus-rest-api/openid-connect/github-actions
#
# 3. Configure your Octopus project details below:
# OCTOPUS_URL: update to your Octopus Instance Url
# OCTOPUS_SERVICE_ACCOUNT: update to your service account Id
# OCTOPUS_SPACE: update to the name of the space your project is configured in
# OCTOPUS_PROJECT: update to the name of your Octopus project
# OCTOPUS_ENVIRONMENT: update to the name of the environment to recieve the first deployment
name: 'Build and Deploy to Octopus Deploy'
on:
push:
branches:
- '$default-branch'
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
env:
DOCKER_REGISTRY: ghcr.io # TODO: Update to your docker registry uri
DOCKER_REGISTRY_USERNAME: ${{ github.actor }} # TODO: Update to your docker registry username
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} # TODO: Update to your docker registry password
outputs:
image_tag: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}
tags: type=semver,pattern={{version}},value=v1.0.0-{{sha}}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy
permissions:
id-token: write
runs-on: ubuntu-latest
needs: [ build ]
env:
OCTOPUS_URL: 'https://your-octopus-url' # TODO: update to your Octopus Instance url
OCTOPUS_SERVICE_ACCOUNT: 'your-service-account-id' # TODO: update to your service account Id
OCTOPUS_SPACE: 'your-space' # TODO: update to the name of the space your project is configured in
OCTOPUS_PROJECT: 'your-project' # TODO: update to the name of your Octopus project
OCTOPUS_ENVIRONMENT: 'your-environment' # TODO: update to the name of the environment to recieve the first deployment
steps:
- name: Login to Octopus Deploy
uses: OctopusDeploy/login@34b6dcc1e86fa373c14e6a28c5507d221e4de629 #v1.0.2
with:
server: '${{ env.OCTOPUS_URL }}'
service_account_id: '${{ env.OCTOPUS_SERVICE_ACCOUNT }}'
- name: Create Release
id: create_release
uses: OctopusDeploy/create-release-action@fea7e7b45c38c021b6bc5a14bd7eaa2ed5269214 #v3.2.2
with:
project: '${{ env.OCTOPUS_PROJECT }}'
space: '${{ env.OCTOPUS_SPACE }}'
packages: '*:${{ needs.build.outputs.image_tag }}'
- name: Deploy Release
uses: OctopusDeploy/deploy-release-action@b10a606c903b0a5bce24102af9d066638ab429ac #v3.2.1
with:
project: '${{ env.OCTOPUS_PROJECT }}'
space: '${{ env.OCTOPUS_SPACE }}'
release_number: '${{ steps.create_release.outputs.release_number }}'
environments: ${{ env.OCTOPUS_ENVIRONMENT }}
@@ -0,0 +1,7 @@
{
"name": "Build and Deploy with Octopus Deploy",
"description": "Build a docker container, create a release in Octopus Deploy and deploy it to your environment.",
"creator": "Octopus Deploy",
"iconName": "octopusdeploy",
"categories": ["Deployment", "Containers", "Dockerfile"]
}
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 48 48" style="enable-background:new 0 0 48 48;" xml:space="preserve">
<style type="text/css">
.st0{fill:#0D80D8;}
</style>
<path class="st0" d="M4.2,36.3C7.8,34,12,30,10.4,25.4c-0.9-2.6-2-4.7-2.3-7.5c-0.1-2.4,0.2-4.7,1-6.8C12.4,2.4,21.9-1.8,30.5,0.8
c7.9,2.4,13.4,11.8,10.1,19.8c-1.9,4.7-2.8,8.4,1.5,12c1.2,1,3.9,2.5,3.9,4.3c0,2.3-4.5-0.5-4.9-0.9c0.6,1,6.2,6.9,2.6,7.3
c-3.3,0.4-6.2-4.3-8.1-6.2c-3.3-3.4-2.8,4-2.8,5.6c0,2.4-1.7,7.3-4.7,4.1c-2.5-2.6-1.5-6.8-3.3-9.8c-1.9-3.2-5.1,3.2-5.9,4.4
c-0.9,1.3-5.3,7.6-7.1,4.3c-1.5-2.7,0.9-7.1,2-9.6c-0.4,0.9-3.3,2.2-4.1,2.6c-1.8,1-3.9,1.5-6,1.4C-1,39.9,2.4,37.5,4.2,36.3z"/>
</svg>

After

Width:  |  Height:  |  Size: 817 B