diff --git a/.env.example b/.env.example index a931650..390c9b0 100644 --- a/.env.example +++ b/.env.example @@ -3,3 +3,7 @@ ROCKETCHAT_BOT_USERNAME=geekbot ROCKETCHAT_BOT_PASSWORD=your-password ROCKETCHAT_MAIN_ADMIN=admin_username STANDUP_DB_PATH=/data/standup-bot.db + +# http_proxy=http://proxy:port +# https_proxy=http://proxy:port +# no_proxy=localhost,127.0.0.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2af188d..02f67cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,22 @@ on: push: branches: [main] pull_request: - branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + - run: go vet ./... + build: runs-on: ubuntu-latest steps: @@ -15,9 +28,34 @@ jobs: with: go-version: "1.22" cache: true - - name: Vet - run: go vet ./... - - name: Build - run: go build ./... - - name: Test - run: go test ./... + - run: go build ./... + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + - run: go test ./... -count=1 -race + + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Smoke test + run: docker build . + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: ${{ github.ref == 'refs/heads/main' }} + tags: | + ghcr.io/sunba91-su/roket.chat-geekbot:latest + ghcr.io/sunba91-su/roket.chat-geekbot:${{ github.sha }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..32a46a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: "1.22" + cache: true + + - name: Vet and test + run: | + go vet ./... + go test ./... -count=1 -race + + - name: Extract version from tag + id: meta + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Log in to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ghcr.io/sunba91-su/roket.chat-geekbot:${{ steps.meta.outputs.VERSION }} + ghcr.io/sunba91-su/roket.chat-geekbot:latest + + - name: Generate release notes + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + name: v${{ steps.meta.outputs.VERSION }} diff --git a/Dockerfile b/Dockerfile index 4ad2bed..63a206e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM golang:1.22-alpine AS builder +FROM golang:1.25-alpine AS builder +ARG http_proxy +ARG https_proxy +ARG no_proxy RUN apk add --no-cache ca-certificates tzdata && \ adduser -D -u 1001 appuser WORKDIR /src diff --git a/Makefile b/Makefile index 22406c4..3e3b4be 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,11 @@ clean: rm -rf $(BIN_DIR)/ docker-build: - docker build -t $(APP_NAME) . + docker build \ + --build-arg http_proxy \ + --build-arg https_proxy \ + --build-arg no_proxy \ + -t $(APP_NAME) . docker-run: docker compose up -d --build diff --git a/docker-compose.yml b/docker-compose.yml index 08562ac..3b36b7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,10 @@ services: build: context: . dockerfile: Dockerfile + args: + http_proxy: "${http_proxy:-}" + https_proxy: "${https_proxy:-}" + no_proxy: "${no_proxy:-}" container_name: geekbot restart: unless-stopped env_file: .env