add actions and devcontainer #10

Merged
mengning merged 6 commits from actions into main 2025-12-21 08:56:40 +00:00
8 changed files with 125 additions and 146 deletions
Showing only changes of commit d9dbc28199 - Show all commits

View File

@@ -10,13 +10,13 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container:
image: gitea/runner-images:ubuntu-latest
# container:
# image: gitea/runner-images:ubuntu-latest
steps:
- name: 拉取代码
uses: https://devstar.cn/actions/checkout@v4
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1
- name: 安装依赖
working-directory:
@@ -32,21 +32,17 @@ jobs:
- name: 构建 Docker 镜像
run: |
docker build -t devstar-docs:${{ gitea.sha }} .
docker build -t devstar.cn/devstar/devstar-docs:latest .
- name: 登录 Docker Registry 并推送镜像
if: github.event_name != 'pull_request'
run: |
echo "${{ secrets.DOCKER_REGISTRY_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} ${{ vars.DOCKER_REGISTRY_ADDRESS }} --password-stdin
docker tag devstar-docs:${{ gitea.sha }} ${{ vars.DOCKER_REGISTRY_ADDRESS }}/${{ vars.DOCKER_REPOSITORY_ARTIFACT}}:${{ gitea.sha }}
docker tag devstar-docs:${{ gitea.sha }} ${{ vars.DOCKER_REGISTRY_ADDRESS }}/${{ vars.DOCKER_REPOSITORY_ARTIFACT}}:latest
docker push ${{ vars.DOCKER_REGISTRY_ADDRESS }}/${{ vars.DOCKER_REPOSITORY_ARTIFACT}}:${{ gitea.sha }}
docker push ${{ vars.DOCKER_REGISTRY_ADDRESS }}/${{ vars.DOCKER_REPOSITORY_ARTIFACT}}:latest
docker push devstar.cn/devstar/devstar-docs:latest
- name: 📝 Update mengning.com.cn通过删除/创建 Application CRD
if: github.event_name != 'pull_request'
env:
DOCKER_REGISTRY_ADDRESS: ${{ vars.DOCKER_REGISTRY_ADDRESS }}
DOCKER_REPOSITORY_ARTIFACT: ${{ vars.DOCKER_REPOSITORY_ARTIFACT }}
DOCKER_IMAGE_TAG: ${{ gitea.sha }}
TLS_CERTIFICATE: ${{ secrets.TLS_CERTIFICATE }}
TLS_PRIVATE_KEY: ${{ secrets.TLS_PRIVATE_KEY }}
run: |
@@ -68,12 +64,14 @@ jobs:
--dry-run=client -o yaml | kubectl apply -f -
rm -f /tmp/tls.crt /tmp/tls.key
# 替换 Application YAML 中的镜像地址变量并应用
sed "s|\${DOCKER_REGISTRY_ADDRESS}|${DOCKER_REGISTRY_ADDRESS}|g; s|\${DOCKER_REPOSITORY_ARTIFACT}|${DOCKER_REPOSITORY_ARTIFACT}|g; s|\${DOCKER_IMAGE_TAG}|${DOCKER_IMAGE_TAG}|g" \
.gitea/workflows/application.yaml > /tmp/application-crd.yaml
# 删除旧的 Application CRD如果存在忽略错误
kubectl delete application mengningsoftware -n web-servers --ignore-not-found=true || true
# 创建新的 Application CRD
kubectl apply -f /tmp/application-crd.yaml
kubectl apply -f deploy.yaml
- name: Clean Environment
if: always()
run: |
docker rmi devstar.cn/devstar/devstar-docs:latest || true
docker builder prune -f || true

View File

@@ -44,7 +44,7 @@ spec:
targetPort: http
template:
type: stateless
image: ${DOCKER_REGISTRY_ADDRESS}/${DOCKER_REPOSITORY_ARTIFACT}:${DOCKER_IMAGE_TAG}
image: devstar.cn/devstar/devstar-docs:latest
ports:
- name: http
port: 80