Deploy with Komodo: main to staging, vX.Y.Z to prod
CI now pushes the Docker image to git.t5de.dev after the tests and deploys it through Komodo (.gitea/scripts/deploy.py): pushes to main as :main to catalog.staging.t5de.dev, vX.Y.Z tags as :X.Y.Z to catalog.t5de.dev, with the version pinned in t5de/t5de-infra. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8742829e77
commit
715c0bd0d7
2 files changed
+144
-1
No files matched your search
+47
-1
@@ -1,4 +1,5 @@
|
||||
# Tests the catalog and builds t5de-catalog for Linux (static) and its Docker image.
|
||||
# Tests the catalog, builds t5de-catalog for Linux (static) and its Docker image, then deploys it: main to staging,
|
||||
# vX.Y.Z tags to prod.
|
||||
name: CI
|
||||
|
||||
on:
|
||||
@@ -35,3 +36,48 @@ jobs:
|
||||
-ldflags "-s -w -buildid= -X git.t5de.dev/t5de/t5de-catalog/internal/buildinfo.Version=${GITHUB_SHA::12}" \
|
||||
-o dist/t5de-catalog ./cmd/t5de-catalog
|
||||
sha256sum dist/t5de-catalog
|
||||
|
||||
# The image for Komodo, then the deploy: main → :main and :sha-<commit>, deployed to staging; vX.Y.Z → :X.Y.Z and
|
||||
# :latest, pinned in t5de/t5de-infra and deployed to prod (.gitea/scripts/deploy.py).
|
||||
deploy:
|
||||
needs: build
|
||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Image tags
|
||||
id: tags
|
||||
run: |
|
||||
if [ "$GITHUB_REF_TYPE" = tag ]; then
|
||||
version=$(echo "$GITHUB_REF_NAME" | sed -nE 's/^v([0-9]+\.[0-9]+\.[0-9]+)$/\1/p')
|
||||
[ -n "$version" ] || { echo "Not a vX.Y.Z tag: $GITHUB_REF_NAME"; exit 1; }
|
||||
echo "tags=$version latest" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "tags=main sha-${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# The build fetches t5de-api from Gitea; --add-host keeps that on the LAN, as the runner does.
|
||||
- name: Build and push
|
||||
env:
|
||||
TAGS: ${{ steps.tags.outputs.tags }}
|
||||
VERSION: ${{ steps.tags.outputs.version }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
echo "$REGISTRY_TOKEN" | docker login git.t5de.dev -u "$GITHUB_ACTOR" --password-stdin
|
||||
image=git.t5de.dev/t5de/t5de-catalog
|
||||
args=(--build-arg "VERSION=$VERSION" --add-host git.t5de.dev:10.10.10.39
|
||||
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
|
||||
--label "org.opencontainers.image.revision=$GITHUB_SHA")
|
||||
for tag in $TAGS; do args+=(-t "$image:$tag"); done
|
||||
docker build "${args[@]}" .
|
||||
for tag in $TAGS; do docker push "$image:$tag"; done
|
||||
|
||||
- name: Deploy
|
||||
env:
|
||||
KOMODO_API_KEY: ${{ secrets.KOMODO_API_KEY }}
|
||||
KOMODO_API_SECRET: ${{ secrets.KOMODO_API_SECRET }}
|
||||
INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
|
||||
run: python3 .gitea/scripts/deploy.py catalog t5de-catalog CATALOG_VERSION
|
||||
Reference in new issue
Block a user