add actions and devcontainer #10
@@ -10,13 +10,13 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
# container:
|
||||||
image: gitea/runner-images:ubuntu-latest
|
# image: gitea/runner-images:ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 拉取代码
|
- name: 拉取代码
|
||||||
uses: https://devstar.cn/actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: 安装依赖
|
- name: 安装依赖
|
||||||
working-directory:
|
working-directory:
|
||||||
@@ -32,21 +32,17 @@ jobs:
|
|||||||
|
|
||||||
- name: 构建 Docker 镜像
|
- name: 构建 Docker 镜像
|
||||||
run: |
|
run: |
|
||||||
docker build -t devstar-docs:${{ gitea.sha }} .
|
docker build -t devstar.cn/devstar/devstar-docs:latest .
|
||||||
|
|
||||||
- name: 登录 Docker Registry 并推送镜像
|
- name: 登录 Docker Registry 并推送镜像
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.DOCKER_REGISTRY_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} ${{ vars.DOCKER_REGISTRY_ADDRESS }} --password-stdin
|
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 push devstar.cn/devstar/devstar-docs:latest
|
||||||
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
|
|
||||||
|
|
||||||
- name: 📝 Update mengning.com.cn(通过删除/创建 Application CRD)
|
- name: 📝 Update mengning.com.cn(通过删除/创建 Application CRD)
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
env:
|
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_CERTIFICATE: ${{ secrets.TLS_CERTIFICATE }}
|
||||||
TLS_PRIVATE_KEY: ${{ secrets.TLS_PRIVATE_KEY }}
|
TLS_PRIVATE_KEY: ${{ secrets.TLS_PRIVATE_KEY }}
|
||||||
run: |
|
run: |
|
||||||
@@ -68,12 +64,14 @@ jobs:
|
|||||||
--dry-run=client -o yaml | kubectl apply -f -
|
--dry-run=client -o yaml | kubectl apply -f -
|
||||||
rm -f /tmp/tls.crt /tmp/tls.key
|
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(如果存在,忽略错误)
|
# 删除旧的 Application CRD(如果存在,忽略错误)
|
||||||
kubectl delete application mengningsoftware -n web-servers --ignore-not-found=true || true
|
kubectl delete application mengningsoftware -n web-servers --ignore-not-found=true || true
|
||||||
|
|
||||||
# 创建新的 Application CRD
|
# 创建新的 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
|
||||||
@@ -44,7 +44,7 @@ spec:
|
|||||||
targetPort: http
|
targetPort: http
|
||||||
template:
|
template:
|
||||||
type: stateless
|
type: stateless
|
||||||
image: ${DOCKER_REGISTRY_ADDRESS}/${DOCKER_REPOSITORY_ARTIFACT}:${DOCKER_IMAGE_TAG}
|
image: devstar.cn/devstar/devstar-docs:latest
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
port: 80
|
port: 80
|
||||||
Reference in New Issue
Block a user