-
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.
Merge pull request #1 from uselagoon/ci-automation
CI automation and initial implementation
- Loading branch information
Showing
15 changed files
with
492 additions
and
39 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,39 @@ | ||
name: Build | ||
on: pull_request | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17" | ||
- name: Set up environment | ||
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: build --snapshot --rm-dist | ||
- name: Login to GHCR | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
id: service_api_meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: uselagoon/lagoon-ssh-portal/service-api | ||
- name: Build and push service-api container image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ steps.service_api_meta.outputs.tags }} | ||
labels: ${{ steps.service_api_meta.outputs.labels }} | ||
file: deploy/service-api/Dockerfile | ||
context: dist/lagoon-ssh-portal_linux_amd64 |
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,22 @@ | ||
name: Lint | ||
on: pull_request | ||
jobs: | ||
golangci-lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2.5.2 | ||
with: | ||
version: latest | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Lint commit messages | ||
uses: wagoid/commitlint-github-action@v4.1.9 |
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,77 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new-tag: ${{ steps.bump-tag.outputs.new }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Configure Git | ||
run: | | ||
git config --global user.name "$GITHUB_ACTOR" | ||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17" | ||
- name: Install ccv | ||
run: > | ||
curl -sSL https://github.com/smlx/ccv/releases/download/v0.3.2/ccv_0.3.2_linux_amd64.tar.gz | ||
| sudo tar -xz -C /usr/local/bin ccv | ||
- name: Bump tag if necessary | ||
id: bump-tag | ||
run: | | ||
if [ -z $(git tag -l $(ccv)) ]; then | ||
git tag $(ccv) | ||
git push --tags | ||
echo "::set-output name=new::true" | ||
fi | ||
release: | ||
needs: tag | ||
if: needs.tag.outputs.new-tag == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17" | ||
- name: Set up environment | ||
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to GHCR | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
id: service_api_meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: uselagoon/lagoon-ssh-portal/service-api | ||
- name: Build and push service-api container image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ steps.service_api_meta.outputs.tags }} | ||
labels: ${{ steps.service_api_meta.outputs.labels }} | ||
file: deploy/service-api/Dockerfile | ||
context: dist/lagoon-ssh-portal_linux_amd64 |
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,44 @@ | ||
name: Tag to Release | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17" | ||
- name: Set up environment | ||
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Login to GHCR | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
id: service_api_meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: uselagoon/lagoon-ssh-portal/service-api | ||
- name: Build and push service-api container image | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ steps.service_api_meta.outputs.tags }} | ||
labels: ${{ steps.service_api_meta.outputs.labels }} | ||
file: deploy/service-api/Dockerfile | ||
context: dist/lagoon-ssh-portal_linux_amd64 |
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,14 @@ | ||
name: Test | ||
on: pull_request | ||
jobs: | ||
go-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.17" | ||
- name: Run Tests | ||
run: go test -v ./... |
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 @@ | ||
/dist |
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,9 @@ | ||
builds: | ||
- dir: cmd/service-api | ||
binary: service-api | ||
ldflags: | ||
- > | ||
-s -w -X main.date={{.Date}} -X "main.goVersion={{.Env.GOVERSION}}" | ||
-X main.shortCommit={{.ShortCommit}} -X main.version={{.Version}} | ||
env: | ||
- CGO_ENABLED=0 |
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
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
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
Oops, something went wrong.