-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: set up GitHub actions for building and deploying API
- Add new file `.github/workflows/api.yml` - Set up environment variables for `GO_VERSION` and `TZ` - Trigger the workflow on push to any branch - Define a job named "buildapi" with a timeout of 20 minutes running on Ubuntu - Checkout the code and set up QEMU and Docker Buildx - Set up Go with version `1.22` and check for the latest version - Install `task` dependency - Build API using `swag` task - Build and push docs API using Docker - Modify file `Taskfile.yml`: Remove `swag` dependency from `codegpt` task - Run formatting tasks: `gomod`, `gencopyright`, `gofmt`, `golint` Signed-off-by: ysicing <[email protected]>
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: api | ||
|
||
env: | ||
# Common versions | ||
GO_VERSION: '1.22' | ||
TZ: Asia/Shanghai | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
buildapi: | ||
name: "api" | ||
timeout-minutes: 20 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ env.GO_VERSION }} | ||
check-latest: true | ||
- name: install task | ||
run: | | ||
echo "install task" | ||
go install github.com/go-task/task/v3/cmd/task@latest | ||
- name: build api | ||
run: | | ||
task swag | ||
- name: Build and push docs api | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ttl.sh/easysoft/zentaoapi | ||
context: docs |
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,31 @@ | ||
FROM golang:alpine as builder | ||
|
||
ENV WORKDIR /go/src/github.com/easysoft/go-zentao/docs | ||
|
||
WORKDIR $WORKDIR | ||
|
||
COPY go.mod go.mod | ||
|
||
COPY go.sum go.sum | ||
|
||
RUN go mod download | ||
|
||
COPY docs.go docs.go | ||
|
||
COPY main.go main.go | ||
|
||
RUN go build -o docsapi && cp docsapi /usr/bin/docsapi | ||
|
||
FROM alpine | ||
|
||
COPY --from=builder /usr/bin/docsapi /root/docsapi | ||
|
||
COPY swagger.json /root/swagger.json | ||
|
||
COPY swagger.yaml /root/swagger.yaml | ||
|
||
WORKDIR /root | ||
|
||
EXPOSE 8080 | ||
|
||
CMD /root/docsapi |
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