diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index e8c9a57..caa8dae 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,37 +1,28 @@ -name-template: 'v$RESOLVED_VERSION' -tag-template: 'v$RESOLVED_VERSION' +name-template: "$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" categories: - - title: '๐Ÿš€ Features' + - title: "๐Ÿš€ Features" labels: - - 'feature' - - 'enhancement' - - title: '๐Ÿ› Bug Fixes' + - "feature" + - "enhancement" + - title: "๐Ÿ› Bug Fixes" labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: '๐Ÿงน Maintenance' + - "bug" + - title: "๐Ÿงฐ Maintenance" labels: - - 'chore' - - 'dependencies' -version-resolver: - major: + - "maintenance" + - title: "๐Ÿ“ฆ Dependencies" labels: - - 'feature' - minor: + - "docker dependency" + - "github dependency" + - "go dependency" + - title: "โœ๏ธ Documentation" labels: - - 'enhancement' - patch: - labels: - - 'fix' - - 'bugfix' - - 'bug' - - 'chore' - - 'dependencies' - default: patch + - "documentation" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +exclude-labels: + - "skip-changelog" template: | ## Changes $CHANGES - - **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION diff --git a/.github/workflows/autodev.yaml b/.github/workflows/autodev.yaml new file mode 100644 index 0000000..c6cf355 --- /dev/null +++ b/.github/workflows/autodev.yaml @@ -0,0 +1,17 @@ +--- +name: Autodev + +on: + push: + branches-ignore: [dev] + pull_request: + types: [labeled, unlabeled, closed] + +jobs: + autodev: + uses: Staffbase/gha-workflows/.github/workflows/template_autodev.yml@v7.6.0 + with: + labels: true + secrets: + app_id: ${{ vars.STAFFBASE_ACTIONS_APP_ID }} + private_key: ${{ secrets.STAFFBASE_ACTIONS_PRIVATE_KEY }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..1072337 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,80 @@ +--- +name: Build & Deploy + +on: + push: + branches: + - main + - dev + pull_request: + types: [opened, synchronize, reopened] + release: + types: [published] + +jobs: + test: + name: Test + runs-on: ubuntu-24.04 + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Test + run: go test ./... + + - name: Build + run: go build -o ./yamllint-action . + + push: + name: Push + needs: test + runs-on: ubuntu-24.04 + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Docker Metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: | + staffbase/yamllint-action + tags: | + type=ref,event=branch + type=semver,pattern={{raw}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and Push Docker Image + id: docker_build + uses: docker/build-push-action@v6 + with: + push: + ${{ github.event_name == 'release' && github.event.action == + 'published' }} + context: . + file: ./Dockerfile + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 92c1928..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -name: CI -on: [push] - -jobs: - test: - runs-on: ubuntu-22.04 - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - - - name: Get dependencies - run: go mod download - - - name: Verify dependencies - run: go mod verify - - - name: Test - run: go test ./... - - release-dry-run: - if: github.ref != 'refs/heads/main' || !startsWith(github.ref, 'refs/tags/') - runs-on: ubuntu-22.04 - steps: - - name: Checkout yamllint action - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - - name: Release Dry Run - uses: goreleaser/goreleaser-action@v6.3.0 - with: - version: latest - args: release --clean --snapshot --skip=announce --skip=publish - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - dependabot-automerge: - name: Auto Merge (Dependabot) - needs: - - test - uses: Staffbase/gha-workflows/.github/workflows/template_automerge_dependabot.yml@v7.6.0 - with: - force: true - secrets: - app_id: ${{ vars.STAFFBASE_ACTIONS_APP_ID }} - private_key: ${{ secrets.STAFFBASE_ACTIONS_PRIVATE_KEY }} diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml deleted file mode 100644 index b172d6b..0000000 --- a/.github/workflows/release-drafter.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Release Drafter - -on: - push: - branches: - - main - pull_request: - types: [opened, reopened, synchronize] - -permissions: - contents: read - -jobs: - update_release_draft: - permissions: - contents: write - pull-requests: write - runs-on: ubuntu-22.04 - steps: - - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..b5fa673 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,14 @@ +--- +name: Release Drafter + +on: + push: + branches: + - main + +jobs: + release: + uses: Staffbase/gha-workflows/.github/workflows/template_release_drafter.yml@v7.6.0 + secrets: + app_id: ${{ vars.STAFFBASE_ACTIONS_APP_ID }} + private_key: ${{ secrets.STAFFBASE_ACTIONS_PRIVATE_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index f6c5356..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v[1-9]+.[0-9]+.[0-9]+' - -jobs: - release: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - - name: Login to docker registry - uses: docker/login-action@v3.4.0 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Release - uses: goreleaser/goreleaser-action@v6.3.0 - with: - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Set major and minor tags - uses: vweevers/additional-tags-action@v2 diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 934d6c8..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,34 +0,0 @@ -before: - hooks: - - go mod tidy -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - goarch: - - amd64 - ldflags: - - -s -w -dockers: - - - goos: linux - goarch: amd64 - image_templates: - - "staffbase/yamllint-action:{{ .Tag }}" - - "staffbase/yamllint-action:{{ .Major }}" - - "staffbase/yamllint-action:{{ .Major }}.{{ .Minor }}" - - "staffbase/yamllint-action:latest" - extra_files: - - entrypoint.sh - -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ .Tag }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' diff --git a/Dockerfile b/Dockerfile index 7a609af..8f57f2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3.13.1-alpine3.19 - -WORKDIR /go/src/github.com/Staffbase/yamllint-action +FROM golang:1.24.1 AS build +WORKDIR /yamllint-action +COPY go.mod go.sum /yamllint-action/ +RUN go mod download +COPY . . +RUN export CGO_ENABLED=0 && go build -o ./yamllint-action . +FROM python:3.13.1-alpine3.19 RUN pip install --no-cache-dir yamllint==1.35.1 && \ adduser --disabled-password --gecos "" --home "/nonexistent" --shell "/sbin/nologin" --no-create-home --uid 10001 appuser - -COPY yamllint-action /yamllint-action +COPY --from=build /yamllint-action/yamllint-action /script_exporter COPY entrypoint.sh /entrypoint.sh - USER appuser:appuser - ENTRYPOINT ["/entrypoint.sh"]