Skip to content

Commit

Permalink
Add setup composite action
Browse files Browse the repository at this point in the history
Signed-off-by: peterdeme <[email protected]>
  • Loading branch information
peterdeme committed Nov 26, 2023
1 parent 0d621bf commit 18aeb2d
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 77 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Build & Publish

on: [push]

Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/goreleaser/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Run GoReleaser
description: Sets up the proper Go version, Docker Buildx, QEMU, and runs GoReleaser

inputs:
snapshot:
description: Whether to create a snapshot release or real one
default: "true"
bugsnag_api_key:
description: The Bugsnag API key
default: "NOT_SET"
repository_url:
description: The repository URL that GoReleaser will use to create the Docker images
required: true
github_token:
description: The GitHub token
required: false
disable_github_release:
description: Whether to disable publishing the GitHub release
default: "true"

runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v4
with: { go-version: "1.20" }

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "linux/amd64,linux/arm64"

- name: Run GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v5
with:
args: release --snapshot=${{ inputs.snapshot }}
env:
BUGSNAG_API_KEY: ${{ inputs.bugsnag_api_key }}
REPOSITORY_URL: ${{ inputs.repository_url }}
GITHUB_TOKEN: ${{ inputs.github_token }}
DISABLE_GITHUB_RELEASE: ${{ inputs.DISABLE_GITHUB_RELEASE }}

outputs:
metadata:
description: The release metadata of GoReleaser
value: ${{ steps.goreleaser.outputs.metadata }}
28 changes: 8 additions & 20 deletions .github/workflows/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ inputs:
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v4
with: { go-version: "1.20" }
- name: Run GoReleaser
uses: ./.github/workflows/goreleaser
with:
snapshot: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}
bugsnag_api_key: ${{ inputs.bugsnag_api_key }}
repository_url: ${{ inputs.ecr_repository_url }}
github_token: ${{ inputs.github_token }}
disable_github_release: ${{ !startsWith(github.ref, 'refs/tags/') }}

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -49,23 +54,6 @@ runs:
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
shell: bash
run: aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
args: release --snapshot=${{ !startsWith(github.ref, 'refs/tags/') }}
env:
BUGSNAG_API_KEY: ${{ inputs.bugsnag_api_key }}
GITHUB_TOKEN: ${{ inputs.github_token }}
REPOSITORY_URL: ${{ inputs.ecr_repository_url }}

- name: Import the PGP key
shell: bash
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1


gosec:
name: 👮‍♀️ GoSec
runs-on: ubuntu-latest
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with: { fetch-depth: 0 }

- name: Setup Go
uses: actions/setup-go@v4
with: { go-version: "1.20" }

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "linux/amd64,linux/arm64"

- name: Run GoReleaser
uses: ./.github/workflows/goreleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v5
with:
args: release --snapshot
env:
BUGSNAG_API_KEY: "REAL_KEY_NOT_NEEDED_HERE"
REPOSITORY_URL: "ghcr.io/spacelift-io/vcs-agent"
repository_url: "ghcr.io/spacelift-io/vcs-agent"

- name: Run Trivy vulnerability scanner (amd64)
uses: aquasecurity/trivy-action@master
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ project_name: spacelift-vcs-agent

builds:
- main: ./cmd/spacelift-vcs-agent
binary: spacelift-vcs-agent
env: [CGO_ENABLED=0]
goos: [windows, linux, darwin]
goarch: [amd64, arm64]
Expand All @@ -14,6 +13,9 @@ builds:
changelog:
use: github-native

release:
disable: "{{ .Env.DISABLE_GITHUB_RELEASE }}"

archives:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
Expand Down

0 comments on commit 18aeb2d

Please sign in to comment.