forked from equinor/flotilla
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 2.15 KB
/
Copy pathrunMigrations.yml
File metadata and controls
75 lines (66 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Run migrations
permissions:
contents: read
pull_requests: read
on:
workflow_call:
inputs:
PullRequestCheckout:
required: false
type: boolean
Environment:
required: true
type: string
CheckoutRef:
required: false
type: string
default: "main"
secrets:
ClientId:
required: true
ClientSecret:
required: true
defaults:
run:
working-directory: backend/api
jobs:
run_migrations:
environment: ${{ inputs.Environment }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.CheckoutRef }}
# Checks out to main branch by default, so we need to manually checkout to the PR the comment was made on
# in order to do the update database on the new migrations.
# We don't have the ref in the IssueComment trigger so we need to check out the pr number
- name: Fetch PR head SHA
if: ${{ inputs.PullRequestCheckout }}
id: pr_head_sha
run: |
PR_SHA=$(gh pr view ${{ github.event.issue.number }} --json headRefOid -q ".headRefOid")
echo "pr_head_sha=$PR_SHA" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Pull Request by SHA
if: ${{ inputs.PullRequestCheckout }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ steps.pr_head_sha.outputs.pr_head_sha }}
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Build project and dependencies
run: dotnet build
- name: Install dotnet ef tool
run: dotnet tool install -g dotnet-ef --version 8.0.11
- name: Update database
run: dotnet ef database update --no-build --verbose
env:
AZURE_CLIENT_ID: ${{ secrets.ClientId }}
AZURE_CLIENT_SECRET: ${{ secrets.ClientSecret }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
ASPNETCORE_ENVIRONMENT: ${{ vars.AspNetEnvironment }}