Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,53 @@
# 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
push: true
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
51 changes: 51 additions & 0 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -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 }}\"}}"