Files
flutter/.gitea/workflows/build-and-deploy.yml
Ruslan Bakiev 4fb691135d
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 2m43s
Configure registry auth for Gitea builds
2026-05-08 13:57:54 +07:00

72 lines
2.6 KiB
YAML

name: Build and deploy Flutter Web
on:
push:
branches:
- main
jobs:
build:
runs-on: build-host
env:
SERVICE_NAME: flutter
IMAGE: gitea.dsrptlab.com/mapflow/flutter:${{ github.sha }}
DOKPLOY_APPLICATION_ID: 9UR7Tpp9v_I6Ueu04sUiu
steps:
- uses: actions/checkout@v4
- name: Configure Gitea registry auth
run: |
set -euo pipefail
mkdir -p ~/.docker
auth="$(printf '%s:%s' "${{ secrets.REGISTRY_USERNAME }}" "${{ secrets.REGISTRY_TOKEN }}" | base64 | tr -d '\n')"
printf '{"auths":{"gitea.dsrptlab.com":{"auth":"%s"}}}\n' "$auth" > ~/.docker/config.json
- name: Build and push image
run: |
set -euo pipefail
builder="mapflow-builder"
if ! docker buildx inspect "$builder" >/dev/null 2>&1; then
docker buildx create --name "$builder" --driver docker-container --buildkitd-config /etc/buildkit/buildkitd.toml
fi
docker buildx use "$builder"
docker buildx inspect --bootstrap
docker buildx build --push --tag "$IMAGE" .
- name: Skip stale deployment
run: |
set -euo pipefail
latest_sha="$(git ls-remote origin refs/heads/main | awk '{print $1}')"
if [ "$latest_sha" = "${GITHUB_SHA}" ]; then
touch .deploy-current
else
echo "A newer main commit exists: $latest_sha. Skipping deploy for ${GITHUB_SHA}."
fi
- name: Update Dokploy image
run: |
set -euo pipefail
[ -f .deploy-current ] || exit 0
payload=$(cat <<JSON
{"applicationId":"$DOKPLOY_APPLICATION_ID","dockerImage":"$IMAGE","username":"${{ secrets.REGISTRY_USERNAME }}","password":"${{ secrets.REGISTRY_TOKEN }}","registryUrl":"gitea.dsrptlab.com"}
JSON
)
curl -fsS -X POST "${{ secrets.DOKPLOY_URL }}/api/application.saveDockerProvider" \
-H "x-api-key: ${{ secrets.DOKPLOY_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$payload"
- name: Deploy in Dokploy
run: |
set -euo pipefail
[ -f .deploy-current ] || exit 0
short_sha="${GITHUB_SHA:0:7}"
payload=$(cat <<JSON
{"applicationId":"$DOKPLOY_APPLICATION_ID","title":"$SERVICE_NAME #${GITHUB_RUN_NUMBER:-0} $short_sha","description":"Deploy registry image $IMAGE"}
JSON
)
curl -fsS -X POST "${{ secrets.DOKPLOY_URL }}/api/application.deploy" \
-H "x-api-key: ${{ secrets.DOKPLOY_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$payload"