This commit is contained in:
xiabin 2025-02-11 10:52:44 +08:00
parent 6670c66559
commit b9de9dbb71

View File

@ -1,25 +1,55 @@
name: Gitea Actions Demo name: Auth & User Management Service CI
#run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push] on:
push:
branches: [main, dev]
paths:
- 'app/auth_service/**'
- 'app/user_management/**'
jobs: jobs:
Explore-Gitea-Actions: build-and-run:
runs-on: runner runs-on: runner
container:
image: golang:alpine
volumes:
- /go/pkg/mod:/go/pkg/mod
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v5
- name: Build Service - name: Build Auth Service
working-directory: ./app/auth_service/auth_service
env:
CGO_ENABLED: 0
run: | run: |
cd app/${{ matrix.service }} go build -v -o auth_service .
go mod tidy mv auth_service ../../../../
go build -o ${{ matrix.service }}_bin ./${{ matrix.service }}
- name: Run Service - name: Build User Management
working-directory: ./app/user_management/user_management
env:
CGO_ENABLED: 0
run: | run: |
cd app/${{ matrix.service }} go build -v -o user_management .
./${{ matrix.service }}_bin -f etc/${{ matrix.service }}.yaml & mv user_management ../../../../
background: true
- name: Keep alive - name: Prepare Docker Environment
run: sleep 300 run: |
cat <<EOF > Dockerfile
FROM alpine
WORKDIR /app
COPY auth_service user_management ./
EXPOSE 8888 8889
CMD ["./auth_service & ./user_management"]
EOF
- name: Build and Run Container
run: |
docker build -t combined-services .
docker run -d \
-p 8888:8888 \
-p 8889:8889 \
--name services-container \
combined-services