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
#run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
name: Auth & User Management Service CI
on:
push:
branches: [main, dev]
paths:
- 'app/auth_service/**'
- 'app/user_management/**'
jobs:
Explore-Gitea-Actions:
build-and-run:
runs-on: runner
container:
image: golang:alpine
volumes:
- /go/pkg/mod:/go/pkg/mod
steps:
- 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: |
cd app/${{ matrix.service }}
go mod tidy
go build -o ${{ matrix.service }}_bin ./${{ matrix.service }}
go build -v -o auth_service .
mv auth_service ../../../../
- name: Run Service
- name: Build User Management
working-directory: ./app/user_management/user_management
env:
CGO_ENABLED: 0
run: |
cd app/${{ matrix.service }}
./${{ matrix.service }}_bin -f etc/${{ matrix.service }}.yaml &
background: true
go build -v -o user_management .
mv user_management ../../../../
- name: Keep alive
run: sleep 300
- name: Prepare Docker Environment
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