-
Notifications
You must be signed in to change notification settings - Fork 2
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 #62 from spacelift-io/main
Production deployment 🎁
- Loading branch information
Showing
8 changed files
with
289 additions
and
38 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Trivy | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
schedule: | ||
- cron: "19 7 * * 0" | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
BASE_NAME: spacelift-vcs-agent | ||
BIN_DIR: build | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: { fetch-depth: 0 } | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: { go-version: 1.18 } | ||
|
||
- name: parse short SHA | ||
id: vars | ||
run: | | ||
echo ::set-output name=sha::$(git rev-parse --short=8 ${{ github.sha }}) | ||
- name: Build Spacelift VCS Agent | ||
run: go build -a -tags netgo -ldflags "-s -w -extldflags '-static' -X main.VERSION=$SHORT_SHA -X main.BugsnagAPIKey=$BUGSNAG_API_KEY" -trimpath -o $BIN_DIR/$BASE_NAME ./cmd/spacelift-vcs-agent | ||
env: | ||
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} | ||
CGO_ENABLED: 0 | ||
SHORT_SHA: ${{ steps.vars.outputs.sha }} | ||
|
||
- name: Archive artifacts for use in Docker build | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
path: | | ||
build | ||
analyze: | ||
name: Analyze with Trivy | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build | ||
path: build | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push the image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: false | ||
load: true | ||
tags: "spacelift-vcs-agent:${{ github.sha }}" | ||
|
||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
image-ref: "spacelift-vcs-agent:${{ github.sha }}" | ||
format: "template" | ||
template: "@/contrib/sarif.tpl" | ||
output: "trivy-results.sarif" | ||
severity: "CRITICAL,HIGH" | ||
|
||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: "trivy-results.sarif" | ||
category: "Trivy" |
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 @@ | ||
FROM alpine:3.18 | ||
|
||
|
||
RUN apk add --no-cache ca-certificates | ||
RUN apk upgrade --update-cache --available | ||
RUN adduser --disabled-password --no-create-home --uid=1983 spacelift | ||
|
||
COPY build/spacelift-vcs-agent /usr/bin/spacelift-vcs-agent | ||
|
||
RUN chmod +x /usr/bin/spacelift-vcs-agent | ||
|
||
CMD ["/usr/bin/spacelift-vcs-agent", "serve"] | ||
|
||
USER spacelift |
Oops, something went wrong.