-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d771f
commit c5259ff
Showing
6 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: "Code QL Configuration" | ||
|
||
paths: | ||
- ./src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" # See documentation for possible values | ||
directory: "/src" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
open-pull-requests-limit: 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: 'Build Docker Image' | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "Dockerfile" | ||
- "src/**" | ||
- ".github/workflows/**" | ||
|
||
# Allows you to run this workflow manually from the Actions tab. We can override the branch, image name, and docker registry. | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'Ref' | ||
required: false | ||
default: '' | ||
image: | ||
description: 'Image Name' | ||
required: true | ||
default: 'mfdlabs/ns1-github-comparator' | ||
registry: | ||
description: 'Docker Registry' | ||
required: true | ||
default: 'docker.io' | ||
|
||
jobs: | ||
build: | ||
if: "!contains(github.event.head_commit.message, '[SKIP IMAGE]')" | ||
runs-on: ubuntu-latest | ||
|
||
# If DOCKER_REGISTRY is not set, default to docker.io | ||
env: | ||
DOCKER_REGISTRY: ${{ github.event.inputs.registry || secrets.DOCKER_REGISTRY || 'docker.io' }} | ||
IMAGE_NAME: ${{ github.event.inputs.image || secrets.IMAGE_NAME || 'mfdlabs/ns1-github-comparator' }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
# Pushes 2 identical images to the registry, one with the tag latest and one with the version from git-ref | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.inputs.ref || github.ref }} | ||
|
||
# Error if IMAGE_NAME is not set | ||
- name: Check IMAGE_NAME | ||
run: | | ||
if [ -z "$IMAGE_NAME" ]; then | ||
echo "IMAGE_NAME is not set" | ||
exit 1 | ||
fi | ||
# Error if DOCKER_USERNAME is not set | ||
- name: Check DOCKER_USERNAME | ||
run: | | ||
if [ -z "$DOCKER_USERNAME" ]; then | ||
echo "DOCKER_USERNAME is not set" | ||
exit 1 | ||
fi | ||
# Error if DOCKER_PASSWORD is not set | ||
- name: Check DOCKER_PASSWORD | ||
run: | | ||
if [ -z "$DOCKER_PASSWORD" ]; then | ||
echo "DOCKER_PASSWORD is not set" | ||
exit 1 | ||
fi | ||
# Login to the registry | ||
- name: Login to registry | ||
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login ${{ env.DOCKER_REGISTRY }} -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | ||
|
||
# Push the image to the registry | ||
- name: Build & Push the image | ||
run: make build-docker IMAGE_NAME=${{ env.IMAGE_NAME }} CI=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Go Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
paths: | ||
- "src/**" | ||
- ".github/workflows/**" | ||
pull_request: | ||
paths: | ||
- "src/**" | ||
- ".github/workflows/**" | ||
|
||
jobs: | ||
lint: | ||
name: Go lint | ||
if: "!contains(toJSON(github.event.commits.*.message), '[SKIP BUILD]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup the Golang environment with version 1.20.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.20.x | ||
|
||
- name: Run lint | ||
working-directory: ./src | ||
run: go mod tidy && go mod vendor && go vet ./... | ||
|
||
build: | ||
name: Build | ||
if: "!contains(toJSON(github.event.commits.*.message), '[SKIP BUILD]')" | ||
needs: lint | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: ["linux", "darwin", "windows"] | ||
arch: ["x86", "x64", "arm", "arm64"] | ||
config: ["debug", "release"] | ||
|
||
steps: | ||
- name: Checkout repository. | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup the Golang environment with version 1.20.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.20.x | ||
|
||
- name: Run the build-<config>-<arch> make target | ||
run: make build-${{ matrix.config }}-${{ matrix.arch }} GOOS=${{ matrix.os }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: CodeQL Analysis | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
pull_request: | ||
branches: | ||
- "master" | ||
|
||
jobs: | ||
codeql: | ||
if: "!contains(toJSON(github.event.commits.*.message), '[SKIP ANALYSIS]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: "go" | ||
config-file: "./.github/configuration/codeql-config.yml" | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Go Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
paths: | ||
- "src/**" | ||
- ".github/workflows/**" | ||
pull_request: | ||
paths: | ||
- "src/**" | ||
- ".github/workflows/**" | ||
|
||
jobs: | ||
test: | ||
name: Go Test | ||
if: "!contains(toJSON(github.event.commits.*.message), '[SKIP TEST]')" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup the Golang environment with version 1.20.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.20.x | ||
|
||
- name: Run Test | ||
run: make test |