Build CI #415
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 CI | |
on: | |
push: | |
branches: | |
- main | |
- 'feature/**' | |
paths: | |
- 'src/**' | |
- 'db/**' | |
- '.github/workflows/build.yml' | |
workflow_dispatch: | |
env: | |
OCTOPUS_PROJECT_NAME: "Trident" | |
OCTOPUS_FEATURE_BRANCH_CHANNEL: Default | |
OCTOPUS_RELEASE_CHANNEL: Release | |
OCTOPUS_SPACE: Default | |
OCTOPUS_API_KEY: ${{ secrets.OCTOPUSSERVERAPIKEY }} | |
OCTOPUS_URL: http://bobjwalker.octopus.app | |
jobs: | |
build-and-push-application: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
dotnet-version: ['8.0.x'] | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
fetch-depth: '0' | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: 5.x | |
- id: determine_version | |
name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
additionalArguments: /overrideconfig mode=Mainline | |
- name: update tag | |
uses: richardsimko/update-tag@v1 | |
with: | |
tag_name: ${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: github.ref == 'refs/heads/main' | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ matrix.dotnet-version }} | |
- name: package database | |
id: "database_package" | |
uses: OctopusDeploy/create-zip-package-action@v3 | |
with: | |
package_id: Trident.Database | |
version: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }}" | |
base_path: "db" | |
files: "**/*" | |
output_folder: packaged | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PAT }} | |
- name: install buildx | |
id: buildx | |
uses: crazy-max/ghaction-docker-buildx@v1 | |
with: | |
version: latest | |
- name: build and push website container | |
working-directory: src | |
run: | | |
docker buildx build --push --platform linux/amd64,linux/arm64 -f "./Trident.Web/Dockerfile" --build-arg APP_VERSION=${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }} --tag bobjwalker99/trident:${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }} --tag bobjwalker99/trident:latest . | |
- name: push packages to Octopus | |
uses: OctopusDeploy/push-package-action@v3 | |
with: | |
packages: | | |
packaged/**/*.zip | |
- name: push build information to Octopus | |
uses: OctopusDeploy/push-build-information-action@v3 | |
with: | |
packages: | | |
Trident.Database | |
Trident | |
version: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}" | |
- name: create release | |
uses: OctopusDeploy/create-release-action@v3 | |
with: | |
project: ${{ env.OCTOPUS_PROJECT_NAME }} | |
channel: ${{ github.ref == 'refs/heads/main' && env.OCTOPUS_RELEASE_CHANNEL || env.OCTOPUS_FEATURE_BRANCH_CHANNEL }} | |
release_number: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }}" | |
package_version: "${{ env.GitVersion_MajorMinorPatch }}.${{ env.GitVersion_PreReleaseNumber || env.GitVersion_PreReleaseTag || github.run_number }}${{ env.GitVersion_PreReleaseLabelWithDash }}" | |
git_ref: ${{ (github.ref_type == 'tag' && github.event.repository.default_branch ) || (github.head_ref || github.ref) }} | |
git_commit: ${{ github.event.after || github.event.pull_request.head.sha }} |