From 2a2e9d1f139e62df8ac7e8fc9b9f701807784b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Somogyi?= Date: Sat, 22 Mar 2025 08:24:36 +0100 Subject: [PATCH] enh: update CI/CD workflows for Docker image builds and add nightly build support doc: docker image versions --- .github/workflows/build-check.yml | 10 ++++- .../workflows/main-docker-pull-nightly.yml | 41 +++++++++++++++++++ .github/workflows/main-docker-pull.yml | 13 +++--- README.md | 6 +++ 4 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/main-docker-pull-nightly.yml diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml index 3f7758e..369a0e2 100644 --- a/.github/workflows/build-check.yml +++ b/.github/workflows/build-check.yml @@ -4,14 +4,20 @@ on: push: branches-ignore: - "main" + paths-ignore: + - 'README.md' + - 'LICENSE' + - 'CHANGELOG.md' + - 'CONTRIBUTING.md' + - 'LICENSE' + - 'doc/**' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - + uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build diff --git a/.github/workflows/main-docker-pull-nightly.yml b/.github/workflows/main-docker-pull-nightly.yml new file mode 100644 index 0000000..f40edc0 --- /dev/null +++ b/.github/workflows/main-docker-pull-nightly.yml @@ -0,0 +1,41 @@ +name: build and pull nightly docker image + +on: + push: + branches: + - "main" + paths-ignore: + - 'README.md' + - 'LICENSE' + - 'CHANGELOG.md' + - 'CONTRIBUTING.md' + - 'LICENSE' + - 'doc/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get the version + id: get_version + run: | + VERSION=$(date +%Y%m%d)-$(git rev-parse --short=6 HEAD)-nightly + echo ::set-output name=VERSION::${VERSION} + - name: Write version to webapp + run: echo "VITE_APP_VERSION=${{ steps.get_version.outputs.VERSION }}" >> webapp/.env.production + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + tags: "${{ secrets.DOCKERHUB_USERNAME }}/httpymonitor:nightly" diff --git a/.github/workflows/main-docker-pull.yml b/.github/workflows/main-docker-pull.yml index 601ba03..14a8ece 100644 --- a/.github/workflows/main-docker-pull.yml +++ b/.github/workflows/main-docker-pull.yml @@ -1,9 +1,6 @@ -name: build and pull latest or versioned docker image +name: build and pull versioned and latest docker image on: - push: - branches: - - "main" release: types: [created] @@ -12,11 +9,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get the version id: get_version run: | - VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'latest') + VERSION=$(git describe --tags --abbrev=0 2>/dev/null || exit 1) echo ::set-output name=VERSION::${VERSION} - name: Write version to webapp run: echo "VITE_APP_VERSION=${{ steps.get_version.outputs.VERSION }}" >> webapp/.env.production @@ -33,4 +30,6 @@ jobs: context: . file: ./Dockerfile push: true - tags: "${{ secrets.DOCKERHUB_USERNAME }}/httpymonitor:${{ steps.get_version.outputs.VERSION }}" + tags: | + "${{ secrets.DOCKERHUB_USERNAME }}/httpymonitor:${{ steps.get_version.outputs.VERSION }}" + "${{ secrets.DOCKERHUB_USERNAME }}/httpymonitor:latest" diff --git a/README.md b/README.md index a93cea5..414b3c2 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ This example: - listens on port `8081` for incoming HTTP requests - names the container `httpymonitor-github-api` +## Docker images versions + +- `nightly`: `smartondev/httpymonitor:nightly` (latest) +- `x.y.z`: `smartondev/httpymonitor:x.y.z` (stable) +- `latest`: `smartondev/httpymonitor:latest` (latest stable) + ## Author [Márton Somogyi](https://github.com/kamarton)