-
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.
- Loading branch information
Showing
2 changed files
with
126 additions
and
11 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
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,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 |