From bb0cddbfe087dd489d95459d3e0ecca458ce10ef Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:17:10 +0100 Subject: [PATCH 1/6] Create octopusdeploy.yml --- .github/workflows/octopusdeploy.yml | 112 ++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/octopusdeploy.yml diff --git a/.github/workflows/octopusdeploy.yml b/.github/workflows/octopusdeploy.yml new file mode 100644 index 0000000..cc0317f --- /dev/null +++ b/.github/workflows/octopusdeploy.yml @@ -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: + - '"master"' + +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: Log in 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 }} From 307ed4ff54f2ad97854f61ed99569acf1d2a19ec Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:24:25 +0100 Subject: [PATCH 2/6] Create main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1 @@ + From 60a2283a5edef36103a25ee9e9e02c245fd4f3a7 Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:47:52 +0100 Subject: [PATCH 3/6] Update octopusdeploy.yml --- .github/workflows/octopusdeploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/octopusdeploy.yml b/.github/workflows/octopusdeploy.yml index cc0317f..b3452b9 100644 --- a/.github/workflows/octopusdeploy.yml +++ b/.github/workflows/octopusdeploy.yml @@ -82,11 +82,11 @@ 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_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 + OCTOPUS_URL: 'https://octopus-operations.octopus.app/' # TODO: update to your Octopus Instance url + OCTOPUS_SERVICE_ACCOUNT: 'LewisGithubActions' # TODO: update to your service account Id + OCTOPUS_SPACE: 'Spaces-1115' # TODO: update to the name of the space your project is configured in + OCTOPUS_PROJECT: 'GitHub-Actions' # TODO: update to the name of your Octopus project + OCTOPUS_ENVIRONMENT: 'Test' # TODO: update to the name of the environment to recieve the first deployment steps: - name: Log in to Octopus Deploy From 1c8f2bf6a08cfb9271ae601c97d02536965fe247 Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 10:56:41 +0100 Subject: [PATCH 4/6] Update octopusdeploy.yml From 74098443dcd5bbfd41572829b97c1da7d724a654 Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:03:19 +0100 Subject: [PATCH 5/6] deploy1 --- .github/workflows/octopusdeploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/octopusdeploy.yml b/.github/workflows/octopusdeploy.yml index b3452b9..f532588 100644 --- a/.github/workflows/octopusdeploy.yml +++ b/.github/workflows/octopusdeploy.yml @@ -28,7 +28,7 @@ name: 'Build and Deploy to Octopus Deploy' - +#new on: push: branches: From 4b03b5b0ebf287dda51228aabfaabc93d2b18439 Mon Sep 17 00:00:00 2001 From: LewisJohnsonOctopus <156933367+LewisJohnsonOctopus@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:33:30 +0100 Subject: [PATCH 6/6] Update octopusdeploy.yml --- .github/workflows/octopusdeploy.yml | 125 +++++----------------------- 1 file changed, 21 insertions(+), 104 deletions(-) diff --git a/.github/workflows/octopusdeploy.yml b/.github/workflows/octopusdeploy.yml index f532588..f0afed7 100644 --- a/.github/workflows/octopusdeploy.yml +++ b/.github/workflows/octopusdeploy.yml @@ -1,32 +1,3 @@ -# 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' #new on: @@ -34,79 +5,25 @@ on: branches: - '"master"' -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 }} +env: + OCTOPUS_PROJECT: GitHub-Actions + OCTOPUS_SPACE: Spaces-1115 + PACKAGE_NAME: PackageName + API_KEY: API-ASADASDASDASKDASKL + OCTOPUS_URL: https://octopus-operations.octopus.app/ - - 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://octopus-operations.octopus.app/' # TODO: update to your Octopus Instance url - OCTOPUS_SERVICE_ACCOUNT: 'LewisGithubActions' # TODO: update to your service account Id - OCTOPUS_SPACE: 'Spaces-1115' # TODO: update to the name of the space your project is configured in - OCTOPUS_PROJECT: 'GitHub-Actions' # TODO: update to the name of your Octopus project - OCTOPUS_ENVIRONMENT: 'Test' # TODO: update to the name of the environment to recieve the first deployment - - steps: - - name: Log in 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 }} +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + + steps: + - 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: '*:${{ env.PACKAGE_NAME }}' + api_key: ${{ env.API_KEY }} + server: ${{ env.OCTOPUS_URL }}