Build images and create release #150
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 images and create Octopus release | |
run-name: 'Build images and create release' | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [opened, reopened, synchronize, labeled, ready_for_review] | |
paths-ignore: | |
- README.md | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- README.md | |
jobs: | |
generate_date_version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.date-version.outputs.version }} | |
steps: | |
- name: Checkout repo so we have local action file | |
uses: actions/checkout@v4 | |
- name: Generate Date Version | |
id: date-version | |
uses: ./.github/actions/date_version | |
build_docker: | |
needs: [generate_date_version] | |
uses: ./.github/workflows/build_app_docker_image.yml | |
with: | |
version: ${{ needs.generate_date_version.outputs.version }} | |
secrets: | |
registry_username: ${{ secrets.CLOUDSMITH_API_ACCOUNT }} | |
registry_password: ${{ secrets.CLOUDSMITH_API_KEY }} | |
nuget_user: ${{ secrets.CLOUDSMITH_API_ACCOUNT }} | |
nuget_password: ${{ secrets.CLOUDSMITH_API_KEY }} | |
build_cnab: | |
uses: ./.github/workflows/build_cnab.yml | |
needs: [generate_date_version] | |
with: | |
version: ${{ needs.generate_date_version.outputs.version }} | |
secrets: | |
registry_username: ${{ secrets.CLOUDSMITH_API_ACCOUNT }} | |
registry_password: ${{ secrets.CLOUDSMITH_API_KEY }} | |
create_release: | |
needs: [build_docker, build_cnab, generate_date_version] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install octopus .NET tool | |
run: | | |
dotnet tool install --global Octopus.DotNet.Cli --version 9.1.7 | |
dotnet octo --version | |
- name: determine if we should create release and deploy | |
id: should-create-release | |
run: | | |
if [[ ${{ github.ref_name == 'main' || github.pull_request.labels.*.name == 'deploy-to-ascn-dev' }} ]]; then | |
echo "SHOULD_CREATE_RELEASE=true" >> $GITHUB_ENV | |
else | |
echo "SHOULD_CREATE_RELEASE=false" >> $GITHUB_ENV | |
fi | |
- name: Create Octo Release if main or deploy to sandbox label present | |
# if: env.SHOULD_CREATE_RELEASE == 'true' | |
run: | | |
octoSpaceId="Default" | |
octoProjectId="opserver" | |
dotnet octo create-release --project=$octoProjectId --space=$octoSpaceId --version=${{ needs.generate_date_version.outputs.version }} \ | |
--server=${{ vars.OCTOPUS_CLOUD_URL }} --apiKey=${{ secrets.OCTOPUS_CLOUD_API_KEY }} | |
- name: Deploy via Octopus if main or deploy to ascn-dev if label present | |
# if: env.SHOULD_CREATE_RELEASE == 'true' | |
run: | | |
octoSpaceId="Default" | |
octoProjectId="opserver" | |
environmentId="${{ github.ref_name == 'main' && 'test' || 'dev' }}" | |
tenantId="${{ github.ref_name == 'main' && 'main' || 'ascn' }}" | |
dotnet octo deploy-release --project=$octoProjectId --space=$octoSpaceId --version=${{ needs.generate_date_version.outputs.version }} \ | |
--server=${{ vars.OCTOPUS_CLOUD_URL }} --apiKey=${{ secrets.OCTOPUS_CLOUD_API_KEY }} --deployTo=$environmentId --tenant=$tenantId | |