This commit is contained in:
+38
-68
@@ -2,13 +2,37 @@ name: Docker Build and Push
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- main
|
- 'v*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push-branches:
|
test:
|
||||||
|
name: Run Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.ref_type == 'branch'
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Run go vet
|
||||||
|
run: go vet ./...
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: go test -v -p 4 ./...
|
||||||
|
|
||||||
|
build-and-push:
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -17,64 +41,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Registry
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.fossy.my.id
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Set version variables
|
|
||||||
id: vars
|
|
||||||
run: |
|
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
|
||||||
echo "VERSION=dev-main" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "VERSION=dev-staging" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
|
|
||||||
echo "COMMIT=${{ github.sha }}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Build and push Docker image for main
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:latest
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ steps.vars.outputs.VERSION }}
|
|
||||||
BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
|
|
||||||
COMMIT=${{ steps.vars.outputs.COMMIT }}
|
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
|
|
||||||
- name: Build and push Docker image for staging
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:staging
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{ steps.vars.outputs.VERSION }}
|
|
||||||
BUILD_DATE=${{ steps.vars.outputs.BUILD_DATE }}
|
|
||||||
COMMIT=${{ steps.vars.outputs.COMMIT }}
|
|
||||||
if: github.ref == 'refs/heads/staging'
|
|
||||||
|
|
||||||
build-and-push-tags:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: git.fossy.my.id
|
registry: git.fossy.my.id
|
||||||
@@ -92,32 +59,35 @@ jobs:
|
|||||||
if echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
|
if echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
|
||||||
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||||
MINOR=$(echo "$VERSION" | cut -d. -f2)
|
MINOR=$(echo "$VERSION" | cut -d. -f2)
|
||||||
|
PATCH=$(echo "$VERSION" | cut -d. -f3 | cut -d- -f1)
|
||||||
|
|
||||||
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
|
echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT
|
||||||
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
|
echo "MINOR=$MINOR" >> $GITHUB_OUTPUT
|
||||||
|
echo "PATCH=$PATCH" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
if echo "$VERSION" | grep -q '-'; then
|
if echo "$VERSION" | grep -q '-'; then
|
||||||
|
PRERELEASE_TAG=$(echo "$VERSION" | cut -d- -f2 | cut -d. -f1)
|
||||||
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
|
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
|
||||||
echo "ADDITIONAL_TAG=staging" >> $GITHUB_OUTPUT
|
echo "PRERELEASE_TAG=$PRERELEASE_TAG" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
|
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
|
||||||
echo "ADDITIONAL_TAG=latest" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Invalid version format: $VERSION"
|
echo "Invalid version format: $VERSION"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build and push Docker image for release
|
- name: Build and push Docker image (release)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.VERSION }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.VERSION }}
|
||||||
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:release
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.MAJOR }}.${{ steps.version.outputs.MINOR }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.MAJOR }}.${{ steps.version.outputs.MINOR }}
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.MAJOR }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.MAJOR }}
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:${{ steps.version.outputs.ADDITIONAL_TAG }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:latest
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.version.outputs.VERSION }}
|
VERSION=${{ steps.version.outputs.VERSION }}
|
||||||
@@ -125,14 +95,14 @@ jobs:
|
|||||||
COMMIT=${{ steps.version.outputs.COMMIT }}
|
COMMIT=${{ steps.version.outputs.COMMIT }}
|
||||||
if: steps.version.outputs.IS_PRERELEASE == 'false'
|
if: steps.version.outputs.IS_PRERELEASE == 'false'
|
||||||
|
|
||||||
- name: Build and push Docker image for pre-release
|
- name: Build and push Docker image (pre-release)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.VERSION }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:v${{ steps.version.outputs.VERSION }}
|
||||||
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:${{ steps.version.outputs.ADDITIONAL_TAG }}
|
git.fossy.my.id/${{ secrets.DOCKER_USERNAME }}/tunnel-please-controller:staging
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.version.outputs.VERSION }}
|
VERSION=${{ steps.version.outputs.VERSION }}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
name: renovate
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * *"
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
renovate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: git.fossy.my.id/renovate-clanker/renovate:latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
- run: renovate
|
|
||||||
env:
|
|
||||||
RENOVATE_CONFIG_FILE: ${{ gitea.workspace }}/renovate-config.js
|
|
||||||
LOG_LEVEL: "debug"
|
|
||||||
RENOVATE_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
|
|
||||||
GITHUB_COM_TOKEN: ${{ secrets.COM_TOKEN }}
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- staging
|
||||||
|
- 'feat/**'
|
||||||
|
|
||||||
|
name: SonarQube Scan
|
||||||
|
jobs:
|
||||||
|
sonarqube:
|
||||||
|
name: SonarQube Trigger
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checking out
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Run go vet
|
||||||
|
run: go vet ./... 2>&1 | tee vet-results.txt
|
||||||
|
|
||||||
|
- name: Run tests with coverage
|
||||||
|
run: |
|
||||||
|
go test ./... -v -p 4 -coverprofile=coverage
|
||||||
|
|
||||||
|
- name: Run GolangCI-Lint Analysis
|
||||||
|
uses: golangci/golangci-lint-action@v9
|
||||||
|
with:
|
||||||
|
skip-cache: true
|
||||||
|
version: v2.6
|
||||||
|
args: >
|
||||||
|
--issues-exit-code=0
|
||||||
|
--output.text.path=stdout
|
||||||
|
--output.checkstyle.path=golangci-lint-report.xml
|
||||||
|
|
||||||
|
- name: SonarQube Scan
|
||||||
|
uses: SonarSource/sonarqube-scan-action@v7.0.0
|
||||||
|
env:
|
||||||
|
SONAR_HOST_URL: ${{ secrets.SONARQUBE_HOST }}
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: >
|
||||||
|
-Dsonar.projectKey=tunnel-please-controller
|
||||||
|
-Dsonar.go.coverage.reportPaths=coverage
|
||||||
|
-Dsonar.test.inclusions=**/*_test.go
|
||||||
|
-Dsonar.test.exclusions=**/vendor/**
|
||||||
|
-Dsonar.exclusions=**/*_test.go,**/vendor/**,**/golangci-lint-report.xml
|
||||||
|
-Dsonar.go.govet.reportPaths=vet-results.txt
|
||||||
|
-Dsonar.go.golangci-lint.reportPaths=golangci-lint-report.xml
|
||||||
|
-Dsonar.sources=./
|
||||||
|
-Dsonar.tests=./
|
||||||
@@ -47,7 +47,6 @@ func main() {
|
|||||||
connect, err := pgx.Connect(ctx, dbURL)
|
connect, err := pgx.Connect(ctx, dbURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer func(connect *pgx.Conn, ctx context.Context) {
|
defer func(connect *pgx.Conn, ctx context.Context) {
|
||||||
err = connect.Close(ctx)
|
err = connect.Close(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user