Skip to content

Commit 2ae1d33

Browse files
committed
feat: add Actions with Docker and semantic-release
1 parent 17b3832 commit 2ae1d33

6 files changed

Lines changed: 149 additions & 3 deletions

File tree

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git/
2+
.gitignore
3+
.github/
4+
.releaserc.json
5+
Dockerfile
6+
*.md
7+
*_test.go
8+
*.test

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, initial]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version: '1.25'
17+
18+
- name: Run tests
19+
run: go test -v -race -coverprofile=coverage.out ./...
20+
21+
- name: Upload coverage
22+
uses: codecov/codecov-action@v4
23+
with:
24+
file: ./coverage.out
25+
26+
lint:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-go@v5
31+
with:
32+
go-version: '1.25'
33+
34+
- name: golangci-lint
35+
uses: golangci/golangci-lint-action@v6
36+
with:
37+
version: latest
38+
39+
build:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.25'
46+
47+
- name: Build binary
48+
run: go build -v -o bin/terraform-gitlab-drift .

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.25'
22+
23+
- name: Semantic Release
24+
uses: cycjimmy/semantic-release-action@v4
25+
with:
26+
extra_plugins: |
27+
@semantic-release/git
28+
@semantic-release/changelog
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to GHCR
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Docker meta
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ghcr.io/${{ github.repository }}
47+
tags: |
48+
type=semver,pattern={{version}}
49+
type=raw,value=latest
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
bin/
22
.idea/
33
.envrc
4+
tmp/
45

56
*.test
67

@@ -11,6 +12,3 @@ profile.cov
1112

1213
go.work
1314
go.work.sum
14-
15-
gitlab_groups.tf
16-
xdeveloperic**

.releaserc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/changelog",
7+
"@semantic-release/github",
8+
[
9+
"@semantic-release/git",
10+
{
11+
"assets": ["CHANGELOG.md"],
12+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
13+
}
14+
]
15+
]
16+
}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM golang:1.25-alpine AS builder
2+
3+
WORKDIR /build
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY . .
9+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o terraform-gitlab-drift .
10+
11+
FROM alpine:3.23.3
12+
13+
RUN apk --no-cache add ca-certificates
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /build/terraform-gitlab-drift .
18+
19+
ENTRYPOINT ["./terraform-gitlab-drift"]

0 commit comments

Comments
 (0)