From c5c5c451704efffe9e1223eecaf968b8120535be Mon Sep 17 00:00:00 2001 From: "a.babushkin" Date: Fri, 14 Aug 2026 15:58:02 +0300 Subject: [PATCH 1/3] Add build --- .github/workflows/docker.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..9567a24 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,50 @@ +name: Docker Image + +on: + push: + tags: + - '**' + branches: + - '**' + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/${{ github.repository_owner }}/github-exporter + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Github Packages + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From aca1e341444635257763ab4dc0e4054281027fc2 Mon Sep 17 00:00:00 2001 From: "a.babushkin" Date: Fri, 14 Aug 2026 16:07:53 +0300 Subject: [PATCH 2/3] Add release with tests --- .github/workflows/ci.yml | 105 +++++++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 50 ----------------- 2 files changed, 105 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d82e4df --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,105 @@ +name: CI + +on: + push: + tags: + - '**' + branches: + - '**' + +jobs: + + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.25 + + - name: Vet + run: go vet ./... + + - name: Test + run: go test ./... + + release: + + needs: test + + if: startsWith(github.ref, 'refs/tags/') + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.25 + + - name: Build + run: | + versionflags="-X main.appVersion=${{ github.ref_name }}" + for GOOS in linux; do + for GOARCH in amd64 arm64; do + export GOOS GOARCH + CGO_ENABLED=0 go build -v -a -tags netgo -ldflags="-extldflags '-static' -s -w $versionflags" -o build/github-exporter-${GOOS}-${GOARCH} cmd/main.go + done + done + cd build; sha256sum * > sha256sums.txt + + - name: Release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true + token: ${{ secrets.GITHUB_TOKEN }} + files: | + build/* + + docker: + + needs: test + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/${{ github.repository_owner }}/github-exporter + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Github Packages + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 9567a24..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Docker Image - -on: - push: - tags: - - '**' - branches: - - '**' - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v3 - with: - images: ghcr.io/${{ github.repository_owner }}/github-exporter - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Github Packages - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} From ea45b8b3fb63608188a092833288d86a137c9961 Mon Sep 17 00:00:00 2001 From: "a.babushkin" Date: Fri, 14 Aug 2026 16:10:56 +0300 Subject: [PATCH 3/3] Build only tags --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d82e4df..5a9b8f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,8 @@ jobs: needs: test + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest steps: @@ -77,9 +79,6 @@ jobs: with: images: ghcr.io/${{ github.repository_owner }}/github-exporter tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}