Build images and create release #182
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 CLI 🐙 | |
uses: OctopusDeploy/install-octopus-cli-action@v3 | |
with: | |
# Not pinning CLI version since we trust Octopus Deploy as one of our direct vendors and this ensures we | |
# keep up-to-date with Octopus Cloud changes | |
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' | |
env: | |
OCTOPUS_URL: ${{ vars.OCTOPUS_CLOUD_URL }} | |
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_CLOUD_API_KEY }} | |
run: | | |
octoSpaceId="Default" | |
octoProjectId="opserver" | |
octopus release create -p $octoProjectId -s $octoSpaceId -v "${{ needs.generate_date_version.outputs.version }}" | |
- name: Deploy via Octopus if main or deploy to ascn-dev if label present | |
# if: env.SHOULD_CREATE_RELEASE == 'true' | |
env: | |
OCTOPUS_URL: ${{ vars.OCTOPUS_CLOUD_URL }} | |
OCTOPUS_API_KEY: ${{ secrets.OCTOPUS_CLOUD_API_KEY }} | |
run: | | |
octoSpaceId="Default" | |
octoProjectId="opserver" | |
environmentId="${{ github.ref_name == 'main' && 'test' || 'dev' }}" | |
tenantId="${{ github.ref_name == 'main' && 'main' || 'ascn' }}" | |
octopus release deploy -p $octoProjectId -s $octoSpaceId --version "${{ needs.generate_date_version.outputs.version }}" \ | |
-e $environmentId --tenant $tenantId |