From 2f72458b310fe99bd3870674905154e1fe2181a0 Mon Sep 17 00:00:00 2001 From: Rob E Date: Wed, 4 Dec 2024 11:51:44 +1000 Subject: [PATCH 1/8] Create Octopus Deploy workflow template --- deployments/octopusdeploy.yml | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 deployments/octopusdeploy.yml diff --git a/deployments/octopusdeploy.yml b/deployments/octopusdeploy.yml new file mode 100644 index 0000000000..21523a85a2 --- /dev/null +++ b/deployments/octopusdeploy.yml @@ -0,0 +1,108 @@ +# This workflow will build and publish a Docker container which is then deplyed through Octopus Deploy. +# +# The build job in this workflow currently assumes 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 Cloud Run' + +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@v1 + with: + server: '${{ env.OCTOPUS_URL }}' + service_account_id: '${{ env.OCTOPUS_SERVICE_ACCOUNT }}' + + - name: Create Release + id: create_release + uses: OctopusDeploy/create-release-action@v3.1.0 + with: + project: '${{ env.OCTOPUS_PROJECT }}' + space: '${{ env.OCTOPUS_SPACE }}' + packages: '*:${{ needs.build.outputs.image_tag }}' + + - name: Deploy Release + uses: OctopusDeploy/deploy-release-action@v3.1.0 + with: + project: '${{ env.OCTOPUS_PROJECT }}' + space: '${{ env.OCTOPUS_SPACE }}' + release_number: '${{ steps.create_release.outputs.release_number }}' + environments: ${{ env.OCTOPUS_ENVIRONMENT }} \ No newline at end of file From 0d302d04fcc8450168893dcb359268066fd75936 Mon Sep 17 00:00:00 2001 From: Rob E Date: Wed, 4 Dec 2024 20:07:32 +1000 Subject: [PATCH 2/8] add properties file --- deployments/properties/octopusdeploy.properties.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 deployments/properties/octopusdeploy.properties.json diff --git a/deployments/properties/octopusdeploy.properties.json b/deployments/properties/octopusdeploy.properties.json new file mode 100644 index 0000000000..49f36db707 --- /dev/null +++ b/deployments/properties/octopusdeploy.properties.json @@ -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": "octopus-deploy", + "categories": ["Deployment", "Containers", "Dockerfile"] +} \ No newline at end of file From 2e34af89adea6e1c1c057bd4ce7c3e5201936694 Mon Sep 17 00:00:00 2001 From: Rob E Date: Wed, 4 Dec 2024 20:18:38 +1000 Subject: [PATCH 3/8] Pin step versions --- deployments/octopusdeploy.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deployments/octopusdeploy.yml b/deployments/octopusdeploy.yml index 21523a85a2..a0575b0520 100644 --- a/deployments/octopusdeploy.yml +++ b/deployments/octopusdeploy.yml @@ -1,3 +1,7 @@ +# 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 deplyed through Octopus Deploy. # # The build job in this workflow currently assumes there is a Dockerfile that generates the relevant application image. @@ -23,7 +27,7 @@ # OCTOPUS_ENVIRONMENT: update to the name of the environment to recieve the first deployment -name: 'Build and Deploy to Cloud Run' +name: 'Build and Deploy to Octopus Deploy' on: push: @@ -86,21 +90,21 @@ jobs: steps: - name: Login to Octopus Deploy - uses: OctopusDeploy/login@v1 + 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@v3.1.0 + 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@v3.1.0 + uses: OctopusDeploy/deploy-release-action@b10a606c903b0a5bce24102af9d066638ab429ac #v3.2.1 with: project: '${{ env.OCTOPUS_PROJECT }}' space: '${{ env.OCTOPUS_SPACE }}' From 12f24ec3a1f643da55edce12cd585fe2a28382ab Mon Sep 17 00:00:00 2001 From: Rob E Date: Thu, 5 Dec 2024 14:28:47 +1000 Subject: [PATCH 4/8] update some text --- deployments/octopusdeploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployments/octopusdeploy.yml b/deployments/octopusdeploy.yml index a0575b0520..fc177f75b0 100644 --- a/deployments/octopusdeploy.yml +++ b/deployments/octopusdeploy.yml @@ -2,9 +2,9 @@ # 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 deplyed through Octopus Deploy. +# This workflow will build and publish a Docker container which is then deployed through Octopus Deploy. # -# The build job in this workflow currently assumes there is a Dockerfile that generates the relevant application image. +# 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. @@ -82,8 +82,8 @@ jobs: 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_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 From 4fcf0d217aa972807266dc1ab1341cbf95b5fc5a Mon Sep 17 00:00:00 2001 From: Rob E Date: Thu, 5 Dec 2024 20:37:29 +1000 Subject: [PATCH 5/8] add octopus icon --- icons/octopus-deploy.svg | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 icons/octopus-deploy.svg diff --git a/icons/octopus-deploy.svg b/icons/octopus-deploy.svg new file mode 100644 index 0000000000..28545cc8ca --- /dev/null +++ b/icons/octopus-deploy.svg @@ -0,0 +1,11 @@ + + + + + From 9f6e4c5cc92f3578c9392583b0d36d94a95cf963 Mon Sep 17 00:00:00 2001 From: Rob E Date: Fri, 13 Dec 2024 07:42:05 +1000 Subject: [PATCH 6/8] added linebreak Co-authored-by: Alexis Abril --- deployments/octopusdeploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/octopusdeploy.yml b/deployments/octopusdeploy.yml index fc177f75b0..cc1f2f4dd3 100644 --- a/deployments/octopusdeploy.yml +++ b/deployments/octopusdeploy.yml @@ -109,4 +109,4 @@ jobs: project: '${{ env.OCTOPUS_PROJECT }}' space: '${{ env.OCTOPUS_SPACE }}' release_number: '${{ steps.create_release.outputs.release_number }}' - environments: ${{ env.OCTOPUS_ENVIRONMENT }} \ No newline at end of file + environments: ${{ env.OCTOPUS_ENVIRONMENT }} From 0fcc15566d7ba01c4f2360b4e5a9d8733bc102b7 Mon Sep 17 00:00:00 2001 From: Rob E Date: Fri, 13 Dec 2024 07:42:23 +1000 Subject: [PATCH 7/8] added linebreak Co-authored-by: Alexis Abril --- deployments/properties/octopusdeploy.properties.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/properties/octopusdeploy.properties.json b/deployments/properties/octopusdeploy.properties.json index 49f36db707..885abaddd6 100644 --- a/deployments/properties/octopusdeploy.properties.json +++ b/deployments/properties/octopusdeploy.properties.json @@ -4,4 +4,4 @@ "creator": "Octopus Deploy", "iconName": "octopus-deploy", "categories": ["Deployment", "Containers", "Dockerfile"] -} \ No newline at end of file +} From fbefeb8eac231282a6d5295a339c1e76ecee73b2 Mon Sep 17 00:00:00 2001 From: Rob E Date: Fri, 13 Dec 2024 07:44:23 +1000 Subject: [PATCH 8/8] update octopusdeploy icon name --- deployments/properties/octopusdeploy.properties.json | 2 +- icons/{octopus-deploy.svg => octopusdeploy.svg} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename icons/{octopus-deploy.svg => octopusdeploy.svg} (100%) diff --git a/deployments/properties/octopusdeploy.properties.json b/deployments/properties/octopusdeploy.properties.json index 885abaddd6..3743ea7fe8 100644 --- a/deployments/properties/octopusdeploy.properties.json +++ b/deployments/properties/octopusdeploy.properties.json @@ -2,6 +2,6 @@ "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": "octopus-deploy", + "iconName": "octopusdeploy", "categories": ["Deployment", "Containers", "Dockerfile"] } diff --git a/icons/octopus-deploy.svg b/icons/octopusdeploy.svg similarity index 100% rename from icons/octopus-deploy.svg rename to icons/octopusdeploy.svg