Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Hoß <[email protected]>
  • Loading branch information
sebhoss committed Sep 8, 2023
1 parent c1eb9d2 commit 8f78193
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: The matrix-alertmanager-receiver Authors
# SPDX-License-Identifier: GPL-3.0-or-later

version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
assignees:
- sebhoss
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
assignees:
- sebhoss
30 changes: 30 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: The matrix-alertmanager-receiver Authors
# SPDX-License-Identifier: GPL-3.0-or-later

name: CodeQL
on:
schedule:
- cron: 42 3 * * SUN
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ go ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
20 changes: 20 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: The matrix-alertmanager-receiver Authors
# SPDX-License-Identifier: GPL-3.0-or-later

name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# SPDX-FileCopyrightText: The matrix-alertmanager-receiver Authors
# SPDX-License-Identifier: GPL-3.0-or-later

name: Automated Release
on:
schedule:
- cron: 23 4 * * MON
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: commits
name: Count Commits
run: echo "count=$(git rev-list --count HEAD --since='last week')" >> $GITHUB_OUTPUT
- id: release
name: Create Release Version
if: steps.commits.outputs.count > 0
run: echo "version=$(date +'%Y.%-m.%-d')" >> $GITHUB_OUTPUT
- id: tag
name: Create Release Tag
if: steps.commits.outputs.count > 0
uses: EndBug/latest-tag@latest
with:
ref: ${{ steps.release.outputs.version }}
- id: setup_go
name: Set up Go
if: steps.commits.outputs.count > 0
uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- id: import_gpg
name: Import GPG key
if: steps.commits.outputs.count > 0
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_SECRET_KEY_BASE64 }}
passphrase: ${{ secrets.GPG_SECRET_KEY_PASSWORD }}
- id: goreleaser
name: Run GoReleaser
if: steps.commits.outputs.count > 0
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: mail
name: Send Mail
if: steps.commits.outputs.count > 0
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.MAIL_SERVER }}
server_port: ${{ secrets.MAIL_PORT }}
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: ${{ github.event.repository.name }} version ${{ steps.release.outputs.version }} published
body: See https://github.com/metio/terraform-provider-git/releases/tag/${{ steps.release.outputs.version }} for details.
to: ${{ secrets.MAIL_RECIPIENT }}
from: ${{ secrets.MAIL_SENDER }}
- id: matrix
name: Send Matrix Message
if: steps.commits.outputs.count > 0
uses: s3krit/[email protected]
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: ${{ github.event.repository.name }} version [${{ steps.release.outputs.version }}](https://github.com/metio/terraform-provider-git/releases/tag/${{ steps.release.outputs.version }}) published
server: ${{ secrets.MATRIX_SERVER }}
16 changes: 16 additions & 0 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: The matrix-alertmanager-receiver Authors
# SPDX-License-Identifier: GPL-3.0-or-later

name: REUSE compliance
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
reuse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v2
52 changes: 52 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: The terraform-provider-git Authors
# SPDX-License-Identifier: 0BSD

name: Verify Commits
on:
push:
branches: [ main ]
paths:
- .github/workflows/verify.yml
- go.mod
- go.sum
- main.go
- alertmanager/**
- config/**
- handler/**
- matrix/**
pull_request:
branches: [ main ]
paths:
- .github/workflows/verify.yml
- go.mod
- go.sum
- main.go
- alertmanager/**
- config/**
- handler/**
- matrix/**
jobs:
test:
name: Tests on ${{ matrix.os }}
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
- id: setup_go
name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- id: tests
name: Run Tests
run: go test ./...

0 comments on commit 8f78193

Please sign in to comment.