Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Build and Update on production workflow #5

Merged
merged 7 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build

on:
push:
branches: ["!main"]
pull_request:
workflow_call:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.19

- name: Cache Go Modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
restore-keys: go-${{ runner.os }}-

- name: Go Modules check
run: |
go get
go mod tidy
# Check if there has been any git changes.
if [[ "$(git status --porcelain)" ]]; then
echo "::error::go mod tidy changed code. Make sure you re-run it."
git diff | colordiff 2> /dev/null
exit 1
fi

- name: Generate
run: |
go generate ./...
# Check if there has been any git changes.
if [[ "$(git status --porcelain)" ]]; then
echo "::error::go generate changed code. Make sure you re-run it."
git diff | colordiff 2> /dev/null
exit 1
fi

- name: Build
run: |
go build -v ./...

- name: Format
run: |
diff=$(gofmt -e -d .)
if [[ "$diff" != "" ]]; then
colordiff 2> /dev/null <<< "$diff"
exit 1
fi

- name: Vet
run: |
go vet ./...

go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck ./...

- name: Test
run: |
go test ./...
22 changes: 22 additions & 0 deletions .github/workflows/update-production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Update on production

on:
push:
branches: ["main"]

jobs:
build:
uses: ./.github/workflows/build.yaml
secrets: inherit

dispatch:
name: Dispatch to acm-aws
needs: build
runs-on: ubuntu-latest
environment: Production
concurrency: Production
steps:
- name: Dispatch workflow
uses: diamondburned/acm-aws/.github/actions/update-pkg@main
token: ${{ secrets.PAT_TOKEN }}
package: sendlimiter
Loading