OIDC login for Octopus Deploy when publishing builds #995
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build, Test, Package and Push | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on pull request events and merges/pushes to main | |
push: | |
branches: | |
- main | |
- release/* | |
tags-ignore: | |
- '**' | |
pull_request: | |
types: [opened, synchronize, reopened] | |
schedule: | |
# Daily 5am australian/brisbane time | |
- cron: '0 19 * * *' | |
workflow_dispatch: | |
# Allows you to run this workflow manually from the Actions tab | |
env: | |
OCTOVERSION_CurrentBranch: ${{ github.head_ref || github.ref }} | |
OCTOPUS_SPACE: Integrations | |
jobs: | |
build: | |
name: "Build, Test and Publish" # Branch protections required check matches against this | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # Required to obtain the ID token from GitHub Actions | |
contents: write # Read Required to check out code, Write to create Git Tags | |
checks: write # Required for test-reporter | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Append OCTOVERSION_CurrentBranch with -nightly-<timestamp> (for scheduled) | |
if: github.event_name == 'schedule' | |
run: | | |
echo "OCTOVERSION_CurrentBranch=${{ env.OCTOVERSION_CurrentBranch }}-nightly-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
- name: Nuke Build | |
id: build | |
run: ./build.sh | |
- name: Publish Test Results | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: Test Results | |
path: ./source/Octopus.Versioning.Tests/TestResults/*.trx | |
reporter: dotnet-trx | |
fail-on-error: true | |
- name: Git Tag (when not pre-release) π·οΈ | |
id: github-tag | |
if: ${{ !contains( steps.build.outputs.octoversion_fullsemver, '-' ) }} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/${{ steps.build.outputs.octoversion_fullsemver }}", | |
sha: context.sha | |
}) | |
- name: Login to Octopus Deploy π | |
if: (! contains(github.ref, '/merge')) && (! contains(github.ref, '/dependabot/')) && (! contains(github.ref, 'prettybot/')) | |
uses: OctopusDeploy/login@v1 | |
with: | |
server: https://deploy.octopus.app | |
service_account_id: c6e32234-4fff-4813-b6be-7b1047b717f0 | |
- name: Push build information to Octopus Deploy π | |
uses: OctopusDeploy/push-build-information-action@v3 | |
if: (! contains(github.ref, '/merge')) && (! contains(github.ref, '/dependabot/')) && (! contains(github.ref, 'prettybot/')) | |
with: | |
packages: | | |
Octopus.Versioning.${{ steps.build.outputs.octoversion_fullsemver }} | |
version: ${{ steps.build.outputs.octoversion_fullsemver }} | |
- name: Push Packages to Octopus Deploy π | |
uses: OctopusDeploy/push-package-action@v3 | |
if: (! contains(github.ref, '/merge')) && (! contains(github.ref, '/dependabot/')) && (! contains(github.ref, 'prettybot/')) | |
with: | |
packages: | | |
./artifacts/Octopus.Versioning.${{ steps.build.outputs.octoversion_fullsemver }}.nupkg | |
- name: Create Octopus Release π | |
uses: OctopusDeploy/create-release-action@v3 | |
if: (! contains(github.ref, '/merge')) && (! contains(github.ref, '/dependabot/')) && (! contains(github.ref, 'prettybot/')) | |
with: | |
project: Versioning | |
release_number: ${{ steps.build.outputs.octoversion_fullsemver }} | |
packages: | | |
Octopus.Versioning:${{ steps.build.outputs.octoversion_fullsemver }} |