File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed
{{cookiecutter.app_name}} Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy
2
+
3
+ on :
4
+ workflow_run :
5
+ workflows :
6
+ - Test
7
+ branches :
8
+ - main
9
+ - master
10
+ - develop
11
+ - development
12
+ types :
13
+ - completed
14
+ workflow_dispatch :
15
+
16
+ jobs :
17
+ deploy :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - name : Checkout
21
+ uses : actions/checkout@v2.3.4
22
+
23
+ - name : Set BRANCH_TAG
24
+ uses : nimblehq/branch-tag-action@v1.2
25
+ with :
26
+ ref : {{ "${{ github.event.workflow_run.head_branch || github.ref }}" }}
27
+
28
+ - name : Set HEROKU_APP_NAME
29
+ run : |
30
+ if [[ $BRANCH_TAG = "latest" ]]
31
+ then
32
+ echo "HEROKU_APP_NAME={{ "${{ secrets.HEROKU_APP_NAME_PRODUCTION }}" }}" >> $GITHUB_ENV
33
+ else
34
+ echo "HEROKU_APP_NAME={{ "${{ secrets.HEROKU_APP_NAME_STAGING }}" }}" >> $GITHUB_ENV
35
+ fi
36
+
37
+ - name : Set DATABASE_URL
38
+ run : |
39
+ if [[ $BRANCH_TAG = "latest" ]]
40
+ then
41
+ echo "DATABASE_URL={{ "${{ secrets.DATABASE_URL_PRODUCTION }}" }}" >> $GITHUB_ENV
42
+ else
43
+ echo "DATABASE_URL={{ "${{ secrets.DATABASE_URL_STAGING }}" }}" >> $GITHUB_ENV
44
+ fi
45
+
46
+ - name : Deploy
47
+ uses : akhileshns/heroku-deploy@v3.8.8
48
+ with :
49
+ heroku_api_key : {{ "${{ secrets.HEROKU_API_KEY }}" }}
50
+ heroku_app_name : $HEROKU_APP_NAME
51
+ heroku_email : {{ "${{ secrets.HEROKU_ACCOUNT_EMAIL }}" }}
52
+ usedocker : true
53
+ docker_build_args : |
54
+ DATABASE_URL
Original file line number Diff line number Diff line change
1
+ FROM golang:1.16-buster
2
+
3
+ ARG DATABASE_URL
4
+
5
+ ENV GIN_MODE=release
6
+
7
+ WORKDIR /app
8
+
9
+ # Install Go dependencies
10
+ COPY go.mod go.sum ./
11
+ RUN go mod download
12
+
13
+ # Install goose for migration
14
+ RUN go get github.com/pressly/goose/cmd/goose
15
+
16
+ # Copy codebase
17
+ COPY . .
18
+
19
+ # Run the migration
20
+ RUN goose -dir database/migrations -table "migration_versions" postgres "$DATABASE_URL" up
21
+
22
+ # Build go application
23
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main ./cmd/api
24
+
25
+ EXPOSE 8080
26
+
27
+ CMD ["./main" ]
You can’t perform that action at this time.
0 commit comments