-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move PR changes to new branch (#287)
- Loading branch information
Showing
9 changed files
with
447 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: build completion | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: 'Environment to deploy to' | ||
required : true | ||
type: choice | ||
default: dev | ||
options: | ||
- dev | ||
- test | ||
- prod | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
runtests: | ||
uses: ./.github/workflows/runtests.yaml | ||
secrets: | ||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
with: | ||
deployment: 'runtests' | ||
environment: 'dev' | ||
testPath: './Equinor.ProCoSys.Completion.sln' | ||
|
||
build-and-push-docker: | ||
needs: runtests | ||
uses: ./.github/workflows/build-and-push-docker.yaml | ||
secrets: | ||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} | ||
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
with: | ||
repositoryName: procosys-completion | ||
dockerFilePath: ./src/Dockerfile | ||
environment: dev | ||
version: 1.000.0.${{github.run_id}} | ||
|
||
deploy-to-radix: | ||
needs: build-and-push-docker | ||
uses: ./.github/workflows/deploy-to-radix.yaml | ||
secrets: | ||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
with: | ||
applicationName: procosys-completion-api | ||
componentName: backend | ||
imageTag: 1.000.0.${{github.run_id}} | ||
environment: dev | ||
|
||
deploy-to-radix-test: | ||
needs: deploy-to-radix | ||
uses: ./.github/workflows/deploy-to-radix.yaml | ||
secrets: | ||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
with: | ||
applicationName: procosys-completion-api | ||
componentName: backend | ||
imageTag: 1.000.0.${{github.run_id}} | ||
environment: test | ||
|
||
deploy-to-radix-prod: | ||
needs: deploy-to-radix-test | ||
uses: ./.github/workflows/deploy-to-radix.yaml | ||
secrets: | ||
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
with: | ||
applicationName: procosys-completion-api | ||
componentName: backend | ||
imageTag: 1.000.0.${{github.run_id}} | ||
environment: prod |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Build and push to Azure Container Registry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
repositoryName: | ||
description: "Name of the repository within Azure Container Registry" | ||
required: true | ||
type: string | ||
dockerFilePath: | ||
description: "File to the docker path" | ||
required: true | ||
type: string | ||
environment: | ||
description: 'Environment to deploy to' | ||
required: true | ||
type: string | ||
version: | ||
description: 'Deploy version' | ||
required: true | ||
type: string | ||
secrets: | ||
AZURE_CLIENT_ID: | ||
required: true | ||
AZURE_CLIENT_SECRET: | ||
required: true | ||
AZURE_TENANT_ID: | ||
required: true | ||
AZURE_SUBSCRIPTION_ID: | ||
required: true | ||
|
||
jobs: | ||
build-and-push-docker: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Azure CLI Login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
- name: Login to Azure Container Registry | ||
run: az acr login --name procosys | ||
- name: Get Access Token | ||
run: | | ||
echo "Retrieving access token..." | ||
TOKEN=$(az account get-access-token --resource=https://pkgs.visualstudio.com --query accessToken -o tsv) | ||
echo "FEED_ACCESSTOKEN=$TOKEN" >> $GITHUB_ENV | ||
- name: Verify Access Token | ||
run: | | ||
echo "Access token starts with: $(echo $FEED_ACCESSTOKEN | cut -c1-10)" | ||
echo "Access token length: $(echo -n $FEED_ACCESSTOKEN | wc -c)" | ||
env: | ||
FEED_ACCESSTOKEN: ${{ env.FEED_ACCESSTOKEN }} | ||
- name: Build and push Docker image | ||
env: | ||
DOCKER_BUILDKIT: 1 # Enable BuildKit for this step | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./src | ||
file: ${{ inputs.dockerFilePath }} | ||
push: true | ||
build-args: | | ||
FEED_ACCESSTOKEN=${{ env.FEED_ACCESSTOKEN }} | ||
AZURE_CLIENT_ID=${{ secrets.AZURE_CLIENT_ID }} | ||
AZURE_TENANT_ID=${{ secrets.AZURE_TENANT_ID }} | ||
secrets: | | ||
AZURE_CLIENT_SECRET=${{ secrets.AZURE_CLIENT_SECRET }} | ||
tags: | | ||
procosys.azurecr.io/api/${{ inputs.repositoryName }}:${{ inputs.version }} | ||
procosys.azurecr.io/api/${{ inputs.repositoryName }}:latest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build and push to Azure Container Registry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
applicationName: | ||
description: "Name of the application within Radix" | ||
required: true | ||
type: string | ||
componentName: | ||
description: "Name of the component within Radix" | ||
required: true | ||
type: string | ||
imageTag: | ||
description: "The tag of the built Docker image" | ||
required: true | ||
type: string | ||
environment: | ||
description: 'Environment to deploy to' | ||
required: true | ||
type: string | ||
secrets: | ||
AZURE_CLIENT_ID: | ||
required: true | ||
AZURE_TENANT_ID: | ||
required: true | ||
AZURE_SUBSCRIPTION_ID: | ||
required: true | ||
|
||
jobs: | ||
deploy-to-radix: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Azure CLI Login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
# Radix | ||
- name: 'Get Azure principal token for Radix' | ||
run: | | ||
token=$(az account get-access-token --resource 6dae42f8-4368-4678-94ff-3960e28e3630 --query=accessToken -otsv) | ||
echo "::add-mask::$token" | ||
echo "APP_SERVICE_ACCOUNT_TOKEN=$token" >> $GITHUB_ENV | ||
- name: Deploy on Radix | ||
uses: equinor/radix-github-actions@v1 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
args: > | ||
create pipeline-job | ||
deploy | ||
-a ${{ inputs.applicationName }} | ||
--from-config | ||
-e ${{ inputs.environment }} | ||
--component ${{ inputs.componentName }} | ||
--image-tag-name ${{ inputs.componentName }}=${{ inputs.imageTag }} | ||
-f |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Test and Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
deployment: | ||
description: 'Deployment type' | ||
required: false | ||
type: string | ||
environment: | ||
description: 'Target environment' | ||
required: true | ||
type: string | ||
testPath: | ||
description: 'Path to the test project' | ||
required: true | ||
type: string | ||
secrets: | ||
AZURE_CLIENT_ID: | ||
required: true | ||
AZURE_TENANT_ID: | ||
required: true | ||
AZURE_SUBSCRIPTION_ID: | ||
required: true | ||
|
||
jobs: | ||
runtests: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Azure CLI Login | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
- name: Azure CLI script | ||
uses: azure/cli@v2 | ||
with: | ||
azcliversion: latest | ||
inlineScript: | | ||
az account show | ||
# You can write your Azure CLI inline scripts here. | ||
- name: Get Access Token | ||
run: | | ||
echo "Retrieving access token..." | ||
TOKEN=$(az account get-access-token --resource=https://pkgs.visualstudio.com --query accessToken -o tsv) | ||
echo "FEED_ACCESSTOKEN=$TOKEN" >> $GITHUB_ENV | ||
- name: Setup dotnet 8 | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
- name: Install dotnet ef | ||
run: dotnet tool install -g dotnet-ef | ||
- name: Configure NuGet source | ||
run: | | ||
dotnet nuget add source --name ProCoSysOfficial \ | ||
--username statoildeveloper \ | ||
--password ${{ env.FEED_ACCESSTOKEN }} \ | ||
--store-password-in-clear-text \ | ||
https://statoildeveloper.pkgs.visualstudio.com/_packaging/ProCoSysOfficial/nuget/v3/index.json | ||
- name: Run tests | ||
run: | | ||
cd src/ | ||
dotnet test ${{ inputs.testPath }} -c Release --logger "trx" | ||
env: | ||
DOTNET_NOLOGO: true | ||
|
||
- name: Publish Test Results | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: TestResults | ||
path: '**/*.trx' | ||
|
||
- name: Deploy | ||
run: | | ||
echo "Deploying to ${{ inputs.environment }}" | ||
echo "Using deployment type: ${{ inputs.deployment }}" |
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
Oops, something went wrong.