Skip to content

Commit

Permalink
test migrate bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Hatleskog committed Dec 5, 2024
1 parent 740a768 commit 8647db1
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/api-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ permissions:
contents: read

jobs:
runtests:
uses: equinor/procosys-completion-api/.github/workflows/runtests.yaml@github-action-pipeline
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_ARTIFACTS_PAT: ${{ secrets.AZURE_ARTIFACTS_PAT }}
with:
deployment: 'runtests'
environment: 'dev'
testPath: './Equinor.ProCoSys.Completion.sln'
# runtests:
# uses: equinor/procosys-completion-api/.github/workflows/runtests.yaml@github-action-pipeline
# secrets:
# AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
# AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
# AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# AZURE_ARTIFACTS_PAT: ${{ secrets.AZURE_ARTIFACTS_PAT }}
# with:
# deployment: 'runtests'
# environment: 'dev'
# testPath: './Equinor.ProCoSys.Completion.sln'

# build-and-push-docker:
# needs: runtests
Expand Down Expand Up @@ -62,3 +62,18 @@ jobs:
# componentName: backend
# imageTag: 1.000.0.${{github.run_id}}
# environment: dev

migrate-dev:
#needs: build-and-push-docker
uses: equinor/procosys-completion-api/.github/workflows/migrate-bundle.yaml@github-action-pipeline
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
DB_CONNECTION_STRING: ${{ secrets.DB_CONNECTION_STRING }}
AZURE_ARTIFACTS_PAT: ${{ secrets.AZURE_ARTIFACTS_PAT }}
with:
workingDirectory: ./src/Equinor.ProCoSys.Completion.Infrastructure
bundleDirectory: ../Equinor.ProCoSys.Completion.WebApi
contextName: CompletionContext
environment: dev
100 changes: 100 additions & 0 deletions .github/workflows/migrate-bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: "🛠️ Migration Bundle"

on:
workflow_call:
inputs:
workingDirectory:
description: "Path for the working directory of the project"
required: true
type: string
bundleDirectory:
description: "Path for the bundle directory"
required: true
type: string
contextName:
description: "Context name for the project/component"
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
DB_CONNECTION_STRING:
required: true
AZURE_ARTIFACTS_PAT:
required: true

jobs:
migrate-dev:
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: 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

# Step 3: Configure NuGet source with access token
- name: Configure NuGet source
run: |
dotnet nuget add source --name ProCoSysOfficial \
--username statoildeveloper \
--password ${{ secrets.AZURE_ARTIFACTS_PAT }} \
--store-password-in-clear-text \
https://statoildeveloper.pkgs.visualstudio.com/_packaging/ProCoSysOfficial/nuget/v3/index.json
- name: create migrations bundle
id: bundle
working-directory: ${{ inputs.workingDirectory }}
run: Global__UseAzureAppConfig="false" FEED_ACCESSTOKEN=${{ secrets.AZURE_ARTIFACTS_PAT }} dotnet ef migrations bundle --self-contained --runtime linux-x64 -s ${{ inputs.bundleDirectory }} --context ${{ inputs.contextName }} -o bundle.exe --verbose
- name: Copy appsettings.json
working-directory: ${{ inputs.workingDirectory }}
run: cp ${{ inputs.bundleDirectory }}/appsettings.json .

- name: Add GitHub Actions IP to Azure SQL Server Firewall
run: |
github_ip_ranges=$(curl -s https://api.github.com/meta | jq -r '.actions[]')
for ip in $github_ip_ranges; do
az sql server firewall-rule create \
--resource-group rg-pcs5-completion-dev \
--server sql-pcs5-completion-dev \
--name GitHubActionsAccess \
--start-ip-address $ip \
--end-ip-address $ip
done
- name: Run bundle
working-directory: ${{ inputs.workingDirectory }}
run: ./bundle.exe --connection ${{ secrets.DB_CONNECTION_STRING }}
env:
DB_CONNECTION_STRING: ${{ secrets.DB_CONNECTION_STRING }}

- name: Remove GitHub Actions IP from Firewall
run: |
az sql server firewall-rule delete \
--resource-group rg-pcs5-completion-dev \
--server sql-pcs5-completion-dev \
--name GitHubActionsAccess

0 comments on commit 8647db1

Please sign in to comment.