File tree Expand file tree Collapse file tree 3 files changed +40
-11
lines changed Expand file tree Collapse file tree 3 files changed +40
-11
lines changed Original file line number Diff line number Diff line change 10
10
branches :
11
11
- main
12
12
13
- permissions : read-all
13
+ permissions :
14
+ contents : read # Set minimal permissions
14
15
15
16
jobs :
16
17
build :
17
18
runs-on : ubuntu-latest
19
+
18
20
steps :
19
- - uses : actions/checkout@v4
21
+ # Checkout code with SHA-pinned action and avoid persisting credentials
22
+ - name : Checkout code
23
+ uses : actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
24
+ with :
25
+ persist-credentials : false # Prevents PRs from gaining access to the repository token
26
+ ref : ${{ github.ref }} # Ensure the checkout uses the exact branch/commit that triggered the workflow
20
27
21
28
- name : Set up Go
22
- uses : actions/setup-go@v4
29
+ uses : actions/setup-go@d60b41a563a30eac31c3ec623e6ff0b3f16e1a06
23
30
with :
24
31
go-version : 1.23.0
25
32
30
37
run : go run github.com/steebchen/prisma-client-go generate
31
38
32
39
- name : Build
33
- run : go build -v ./...
40
+ run : |
41
+ echo "Building the application..."
42
+ go build -v ./...
34
43
35
44
- name : Test
36
- run : go test -v ./...
45
+ run : |
46
+ echo "Running tests..."
47
+ go test -v ./...
Original file line number Diff line number Diff line change 1
1
name : Prisma Migrations
2
2
3
3
on :
4
- workflow_dispatch : # Allows manually triggering migrations from the GitHub Actions UI
4
+ workflow_dispatch : # Allows manual triggering of migrations from the GitHub Actions UI
5
5
push :
6
6
branches :
7
7
- main
8
8
paths :
9
- - " prisma/**" # Only trigger on changes to Prisma files or schema
9
+ - " prisma/**" # Only trigger on changes to Prisma files or schema
10
10
11
- permissions : read-all
11
+ permissions :
12
+ contents : read # Limit permissions to read-only by default
12
13
13
14
jobs :
14
15
migrate :
15
16
runs-on : ubuntu-latest
17
+ environment : production # Ensure this matches your GitHub environment setup with protection rules
18
+
16
19
steps :
17
- - uses : actions/checkout@v4
20
+ - name : Checkout repository
21
+ uses : actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # protects against any unintentional or malicious modifications
22
+ with :
23
+ persist-credentials : false # Prevent PRs from gaining access to the repository token
24
+ ref : ${{ github.ref }} # Ensure checkout uses the exact branch or commit that triggered the workflow
18
25
19
26
- name : Set up Go
20
- uses : actions/setup-go@v4
27
+ uses : actions/setup-go@d60b41a563a30eac31c3ec623e6ff0b3f16e1a06
21
28
with :
22
29
go-version : 1.23.0
23
30
30
37
- name : Run Prisma Migrations
31
38
env :
32
39
DATABASE_URL : ${{ secrets.DATABASE_URL }}
33
- run : go run github.com/steebchen/prisma-client-go migrate deploy
40
+ run : |
41
+ # Store the DATABASE_URL in a local variable to avoid exposing it directly
42
+ DB_URL="$DATABASE_URL"
43
+
44
+ # Prevent potential injections by avoiding direct use of the environment variable
45
+ if [ -z "$DB_URL" ]; then
46
+ echo "DATABASE_URL is not set"
47
+ exit 1
48
+ fi
49
+ echo "Starting Prisma migrations..."
50
+ go run github.com/steebchen/prisma-client-go migrate deploy
Original file line number Diff line number Diff line change
1
+ .github /workflows /* @ romelgomez
You can’t perform that action at this time.
0 commit comments