From 07c1530bb4da8de4ef3c151ccbecbcd2cd67e9a5 Mon Sep 17 00:00:00 2001 From: Eric Brousseau Date: Sat, 29 Aug 2026 08:04:49 -0700 Subject: [PATCH] updates ci with new version bump --- .github/workflows/docker-ci.yml | 35 ++++++++++++++------ .github/workflows/version-bump.yml | 51 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index 2ac1aa9..41017b5 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -1,33 +1,37 @@ -# This workflow builds and pushes the Docker image for the Libowski Bot service to Docker Hub. +# This workflow builds and pushes the Docker image for the node service to Docker Hub. name: Docker CI for Libowski Bot +run-name: v${{ github.event.client_payload.version }} on: - push: - branches: - - main + repository_dispatch: + types: [version-bumped] jobs: - build-and-push-libowski-image: + build-and-push-next-image: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 + + - name: Read version + id: pkg + run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT" - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + uses: docker/setup-qemu-action@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4 - name: Log in to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and Push Docker Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v7 with: context: . file: ./Dockerfile @@ -35,4 +39,15 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/libowski-bot:latest ${{ secrets.DOCKERHUB_USERNAME }}/libowski-bot:${{ github.sha }} + ${{ secrets.DOCKERHUB_USERNAME }}/libowski-bot:${{ steps.pkg.outputs.version }} platforms: linux/amd64,linux/arm64 + + deploy: + needs: build-and-push-next-image + runs-on: [self-hosted, Linux, ARM64] + steps: + - name: Pull and restart + run: | + cd /home/eric/rpi-docker-compose + docker compose pull + docker compose up -d diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 0000000..3bee26b --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,51 @@ +name: version-bump + +on: + pull_request: + types: [closed] + branches: [main] + +permissions: + contents: write + +jobs: + bump: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v7 + with: + ref: main + fetch-depth: 0 + + - name: Determine bump level + id: level + run: | + LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}' + if echo "$LABELS" | grep -qi '"major"'; then + echo "level=major" >> "$GITHUB_OUTPUT" + elif echo "$LABELS" | grep -qi '"minor"'; then + echo "level=minor" >> "$GITHUB_OUTPUT" + else + echo "level=patch" >> "$GITHUB_OUTPUT" + fi + + - name: Bump version, commit, tag + run: | + git config user.name "vault-agent" + git config user.email "vault-agent@users.noreply.github.com" + npm version ${{ steps.level.outputs.level }} -m "v%s [skip ci]" + git push origin main --follow-tags + + - name: Read new version + id: newver + run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT" + + - name: Notify Docker CI + run: | + curl -s -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${{ github.repository }}/dispatches \ + -d "{\"event_type\":\"version-bumped\",\"client_payload\":{\"version\":\"${{ steps.newver.outputs.version }}\"}}"