mirror of
https://github.com/taylanbakircioglu/haproxy-openmanager.git
synced 2026-09-12 05:48:58 +00:00
60f4fa71ed
The version.json single-source move (v1.8.7) updated the version READ step but missed the create-release step, which still ran jq against the deleted repo-root version.json and failed the workflow. Point it at backend/version.json. This release step is public-only (GitHub Releases), so it has no corporate counterpart.
98 lines
3.6 KiB
YAML
98 lines
3.6 KiB
YAML
name: build and push docker images
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
|
|
jobs:
|
|
build_and_push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: generate version tag
|
|
id: version
|
|
run: echo "TAG=$(date +'%Y%m%d.%H%M')" >> $GITHUB_OUTPUT
|
|
|
|
- name: read product version
|
|
id: prodversion
|
|
run: |
|
|
VERSION=$(jq -r .version backend/version.json)
|
|
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
|
|
echo "Failed to read product version from backend/version.json" >&2
|
|
exit 1
|
|
fi
|
|
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
# version.json now lives at backend/version.json (inside the ./backend build
|
|
# context), so `COPY . .` bakes it into the image directly — no staging step
|
|
# is needed and the backend reports the correct version in every deployment,
|
|
# not just this workflow's builds.
|
|
- name: set up qemu
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: set up docker buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: login to docker hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: build & push backend
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./backend
|
|
file: ./backend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
taylanbakircioglu/haproxy-openmanager-backend:latest
|
|
taylanbakircioglu/haproxy-openmanager-backend:${{ steps.version.outputs.TAG }}
|
|
taylanbakircioglu/haproxy-openmanager-backend:${{ steps.prodversion.outputs.VERSION }}
|
|
|
|
- name: build & push frontend
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./frontend
|
|
file: ./frontend/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: |
|
|
taylanbakircioglu/haproxy-openmanager-frontend:latest
|
|
taylanbakircioglu/haproxy-openmanager-frontend:${{ steps.version.outputs.TAG }}
|
|
taylanbakircioglu/haproxy-openmanager-frontend:${{ steps.prodversion.outputs.VERSION }}
|
|
|
|
# Keep the GitHub Releases/Tags in sync with version.json. The docker
|
|
# images above are tagged with the product version, but nothing here
|
|
# created the matching git tag, so the repo's Tags/Releases drifted
|
|
# behind (stuck at the last manually-created tag). After the images are
|
|
# pushed, cut a Release (which also creates the tag) for the current
|
|
# version.json, but only if one does not already exist, so re-runs
|
|
# without a version bump are a no-op.
|
|
- name: create github release from version.json
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
VERSION="${{ steps.prodversion.outputs.VERSION }}"
|
|
TAG="v${VERSION}"
|
|
RELEASE_NAME=$(jq -r '.releaseName // empty' backend/version.json)
|
|
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
echo "Release $TAG already exists, skipping."
|
|
else
|
|
TITLE="$TAG"
|
|
[ -n "$RELEASE_NAME" ] && TITLE="$TAG — $RELEASE_NAME"
|
|
gh release create "$TAG" \
|
|
--repo "$GITHUB_REPOSITORY" \
|
|
--target "$GITHUB_SHA" \
|
|
--title "$TITLE" \
|
|
--notes "Automated release for $TAG (from version.json)."
|
|
echo "Created release $TAG"
|
|
fi
|
|
|