92 lines
3.0 KiB
YAML
92 lines
3.0 KiB
YAML
name: Build Push and Deploy
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
docker-image:
|
|
runs-on: node
|
|
permissions:
|
|
contents: read
|
|
defaults:
|
|
run:
|
|
shell: sh
|
|
|
|
steps:
|
|
- name: Ensure Git is available
|
|
run: |
|
|
if command -v git >/dev/null 2>&1; then
|
|
git --version
|
|
exit 0
|
|
fi
|
|
|
|
if command -v apt-get >/dev/null 2>&1; then
|
|
apt-get update && apt-get install -y git
|
|
elif command -v apk >/dev/null 2>&1; then
|
|
apk add --no-cache git
|
|
elif command -v dnf >/dev/null 2>&1; then
|
|
dnf install -y git
|
|
elif command -v yum >/dev/null 2>&1; then
|
|
yum install -y git
|
|
else
|
|
echo "No supported package manager found to install git"
|
|
exit 1
|
|
fi
|
|
|
|
git --version
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: ${{ github.server_url }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.REGISTRY_HOST }}
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Build and Push Image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ vars.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }}
|
|
${{ vars.REGISTRY_HOST }}/${{ github.repository }}:latest
|
|
build-args: |
|
|
NEXT_PUBLIC_BACKEND_URL=${{ vars.NEXT_PUBLIC_BACKEND_URL }}
|
|
NEXT_PUBLIC_COPILOT_URL=${{ vars.NEXT_PUBLIC_COPILOT_URL }}
|
|
NEXT_PUBLIC_AUDIO_SERVICE_URL=${{ vars.NEXT_PUBLIC_AUDIO_SERVICE_URL }}
|
|
NEXT_PUBLIC_MAP_URL=${{ vars.NEXT_PUBLIC_MAP_URL }}
|
|
NEXT_PUBLIC_MAP_WORKSPACE=${{ vars.NEXT_PUBLIC_MAP_WORKSPACE }}
|
|
NEXT_PUBLIC_MAP_EXTENT=${{ vars.NEXT_PUBLIC_MAP_EXTENT }}
|
|
NEXT_PUBLIC_NETWORK_NAME=${{ vars.NEXT_PUBLIC_NETWORK_NAME }}
|
|
NEXT_PUBLIC_MAPBOX_TOKEN=${{ secrets.NEXT_PUBLIC_MAPBOX_TOKEN }}
|
|
NEXT_PUBLIC_TIANDITU_TOKEN=${{ secrets.NEXT_PUBLIC_TIANDITU_TOKEN }}
|
|
|
|
- name: Notify Deploy Server
|
|
if: success()
|
|
env:
|
|
IMAGE: ${{ vars.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }}
|
|
run: |
|
|
curl -fsSL -X POST "${{ vars.DEPLOY_WEBHOOK_URL }}" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer ${{ secrets.DEPLOY_WEBHOOK_TOKEN }}" \
|
|
-d "{\"image\":\"${IMAGE}\",\"tag\":\"${{ github.ref_name }}\",\"repo\":\"${{ github.repository }}\"}"
|
|
|
|
deploy-fallback-log:
|
|
runs-on: node
|
|
needs: docker-image
|
|
if: failure()
|
|
steps:
|
|
- name: Deployment not triggered
|
|
run: echo "Image build/push failed, deployment webhook was not called."
|