From 0e8d0a7dc5ce4fc678b779102adfd7ffbcaff1c0 Mon Sep 17 00:00:00 2001 From: Eric Brousseau Date: Sun, 23 Aug 2026 17:51:40 -0700 Subject: [PATCH] Switch Docker CI trigger to repository_dispatch for accurate version in run title --- .github/workflows/main.yml | 25 ++++++++------- .github/workflows/version-bump.yml | 51 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/version-bump.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67559fc..9fcf0fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,33 +1,35 @@ -# This workflow builds and pushes the Docker image to Docker Hub. - name: Docker CI for main branch +run-name: v${{ github.event.client_payload.version }} on: - push: - branches: - - main + repository_dispatch: + types: [version-bumped] jobs: - build-and-push-node-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 +37,5 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/vpc-data:latest ${{ secrets.DOCKERHUB_USERNAME }}/vpc-data:${{ github.sha }} + ${{ secrets.DOCKERHUB_USERNAME }}/vpc-data:${{ steps.pkg.outputs.version }} platforms: linux/amd64,linux/arm64 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 }}\"}}"