ref:数据库切换到postgresql #41
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
name: Test When Commit.yml | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:latest | |
options: --privileged | |
ports: | |
- 80:80 | |
- 8000:8000 | |
- 3000:3000 | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock | |
steps: | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
docker-compose --version | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# # 构建单架构后端服务镜像用于本地测试 | |
# - name: Build backend service image for testing | |
# run: docker build -t backend:test -f ./Django/Dockerfile ./Django | |
# | |
# # 构建单架构前端服务镜像用于本地测试 | |
# - name: Build web service image for testing | |
# run: docker build -t web:test -f ./astro/Dockerfile ./astro | |
# # 构建单架构 Nginx 服务镜像用于本地测试 | |
# - name: Build nginx service image for testing | |
# run: docker build -t nginx:test -f ./nginx/nginx.Dockerfile . | |
# 启动 Docker Compose 服务用于测试 | |
- name: Start Docker Compose services for testing | |
run: docker compose -f "./GitHub Action Build Docker.yml" up --build -d | |
- name: Wait for services to be up | |
run: | | |
echo "Waiting for services to be up..." | |
sleep 10 | |
- name: Check logs | |
run: | | |
docker compose logs backend | |
docker compose logs web | |
- name: Run tests | |
run: | | |
curl -f http://localhost:3000 | |
curl -f http://localhost:3000/posts/1 | |
curl -f http://localhost:3000/archive | |
curl -f http://localhost:3000/about | |
curl -f http://localhost:8000/admin | |
curl -f http://localhost:8000/api/posts/ | |
curl -f http://localhost:8000/api/web_config |