diff --git a/.github/actions/setup-and-build/action.yml b/.github/actions/setup-and-build/action.yml new file mode 100644 index 00000000..3d36559b --- /dev/null +++ b/.github/actions/setup-and-build/action.yml @@ -0,0 +1,16 @@ +name: Setup Go and Build +description: Checkout repo, set up Go version from go.mod, and compile the project + +runs: + using: composite + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-go@v6 + with: + go-version-file: 'go.mod' + cache: true + + - name: Build + shell: bash + run: go build ./... diff --git a/.github/workflows/dependabot-build-check.yml b/.github/workflows/dependabot-build-check.yml index 54865acc..09a5cc26 100644 --- a/.github/workflows/dependabot-build-check.yml +++ b/.github/workflows/dependabot-build-check.yml @@ -12,20 +12,4 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout PR branch - uses: actions/checkout@v6 - - - name: Set up Go - uses: actions/setup-go@v6 - with: - go-version: '1.25' - - - name: Build Go project - run: | - echo "Building Go project..." - go build ./... - if [ $? -ne 0 ]; then - echo "Go build failed!" - exit 1 - fi - echo "Go build successful!" + - uses: ./.github/actions/setup-and-build diff --git a/.github/workflows/go-build-deploy.yml b/.github/workflows/go-build-deploy.yml index e404caf3..3369cabc 100644 --- a/.github/workflows/go-build-deploy.yml +++ b/.github/workflows/go-build-deploy.yml @@ -12,15 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version: '1.25' - cache: true - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Restore build cache uses: actions/cache@v5 diff --git a/.github/workflows/newsletter.yml b/.github/workflows/newsletter.yml index 317b20c1..31508614 100644 --- a/.github/workflows/newsletter.yml +++ b/.github/workflows/newsletter.yml @@ -12,14 +12,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version: '1.25' - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Post to Buttondown env: diff --git a/.github/workflows/sync-build-deploy.yml b/.github/workflows/sync-build-deploy.yml index 2ec4c770..e4995eec 100644 --- a/.github/workflows/sync-build-deploy.yml +++ b/.github/workflows/sync-build-deploy.yml @@ -15,14 +15,7 @@ jobs: contents: write steps: - - uses: actions/checkout@v6 - - - uses: actions/setup-go@v6 - with: - go-version: '1.25' - - - name: Build - run: go build ./... + - uses: ./.github/actions/setup-and-build - name: Create credentials.json run: |