ci: use change filters for workflows

This commit is contained in:
Sirz Benjie 2025-09-26 15:15:14 -05:00
parent a6aec58c62
commit 4d7fe4e473
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
5 changed files with 71 additions and 5 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*.yml]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

View File

@ -8,7 +8,14 @@ permissions:
contents: read
jobs:
changes:
uses: ./.github/workflows/filter-changes.yml
permissions:
pull-requests: read
contents: read
build:
needs: changes
if: ${{ needs.changes.outputs.ci == 'true' }} && github.repository == 'pagefaultgames/rogueserver'
name: Build (${{ matrix.os_name }})
env:
GO_VERSION: 1.22
@ -25,9 +32,9 @@ jobs:
- os: windows-latest
os_name: windows
arch: amd64
# TODO macos needs universal binary!
# - os: macos-latest
# os_name: macos
# TODO macos needs universal binary!
# - os: macos-latest
# os_name: macos
steps:
- uses: actions/checkout@v4
- name: Set up Go ${{ env.GO_VERSION }}
@ -43,7 +50,7 @@ jobs:
version: latest
args: --config .golangci.yml
- name: Test
run: go test -v
run: go test -v ./...
- name: Build
run: go build -v
- name: Upload artifact

38
.github/workflows/filter-changes.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Path Filters
on:
workflow_call:
permissions:
pull-requests: read
contents: read
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
ci: ${{ steps.filter.outputs.ci }}
ghcr: ${{ steps.filter.outputs.ghcr }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
common: &common
- '**/*.go'
- go.mod
- go.sum
ghcr:
- *common
- .dockerignore
- Dockerfile
- docker-compose.Development.yml
ci:
- *common
- .golangci.yml

View File

@ -10,9 +10,16 @@ permissions:
packages: write
jobs:
changes:
uses: ./.github/workflows/filter-changes.yml
permissions:
pull-requests: read
contents: read
build:
needs: changes
name: Build and publish to GHCR
if: github.repository == 'pagefaultgames/rogueserver'
if: ${{ needs.changes.outputs.ghcr == 'true' }} && github.repository == 'pagefaultgames/rogueserver'
env:
GO_VERSION: 1.22
runs-on: ubuntu-latest

View File

@ -12,6 +12,7 @@ path = [
"go.sum",
"go.mod",
".github/FUNDING.yml",
"**/*.editorconfig",
]
SPDX-FileCopyrightText = "NONE"
SPDX-License-Identifier = "CC0-1.0"