diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d921d0f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/gochecks.yml b/.github/workflows/gochecks.yml new file mode 100644 index 0000000..ab64b95 --- /dev/null +++ b/.github/workflows/gochecks.yml @@ -0,0 +1,36 @@ +name: Checks +on: + pull_request: + branches: + - main +jobs: + Golangci-Lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: "latest" + args: "./..." + Go-Fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - name: Run fmt + run: | + gofmt_files=$(gofmt -l cmd) + if [[ -n ${gofmt_files} ]]; then + echo 'gofmt needs running on the following files:' + echo "${gofmt_files}" + exit 1 + fi + exit 0 \ No newline at end of file diff --git a/.github/workflows/notify-issue.yml b/.github/workflows/notify-issue.yml new file mode 100644 index 0000000..6a05ea3 --- /dev/null +++ b/.github/workflows/notify-issue.yml @@ -0,0 +1,17 @@ +name: notify-issue + +on: + issues: + types: [opened] + +jobs: + issue: + runs-on: ubuntu-latest + name: New Issue Notification + steps: + - uses: mattermost/action-mattermost-notify@2.0.0 + with: + MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} + MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} + MATTERMOST_ICON_URL: ${{ secrets.MATTERMOST_ICON }} + TEXT: "${{ github.repository }}: New Issue https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}" diff --git a/.github/workflows/notify-pr.yml b/.github/workflows/notify-pr.yml new file mode 100644 index 0000000..45e16e8 --- /dev/null +++ b/.github/workflows/notify-pr.yml @@ -0,0 +1,15 @@ +name: notify-pr + +on: pull_request_target + +jobs: + pr: + runs-on: ubuntu-latest + name: Pull Request Notification + steps: + - uses: mattermost/action-mattermost-notify@2.0.0 + with: + MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} + MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} + MATTERMOST_ICON_URL: ${{ secrets.MATTERMOST_ICON }} + TEXT: "${{ github.repository }} : PR https://github.com/${{ github.repository }}/pull/${{ github.event.number }}" \ No newline at end of file diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml new file mode 100644 index 0000000..fbada1b --- /dev/null +++ b/.github/workflows/releaser.yml @@ -0,0 +1,91 @@ +name: "Automatic Releaser" + +on: + push: + branches: + - master + +permissions: + contents: write + +jobs: + check-commit: + runs-on: ubuntu-latest + outputs: + msg_check: ${{ steps.check-msg.outputs.match }} + steps: + - name: Check Message + id: check-msg + run: | + pattern="^Release v[0-9]+.[0-9]+.[0-9]+ #(minor|major|patch)$" + if [[ "${{ github.event.head_commit.message }}" =~ ${pattern} ]]; then + echo ::set-output name=match::true + fi + create-tag: + runs-on: ubuntu-latest + if: needs.check-commit.outputs.msg_check == 'true' + needs: check-commit + outputs: + new_tag: ${{ steps.tagger.outputs.new_tag }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Bump version and push tag + id: tagger + uses: anothrNick/github-tag-action@1.36.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: true + DEFAULT_BUMP: "none" + + goreleaser: + runs-on: ubuntu-latest + needs: create-tag + steps: + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - + name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.21" + - + name: Docker Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.VULTRBOT_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - + name: Clear + if: always() + run: | + rm -f ${HOME}/.docker/config.json + + release: + runs-on: ubuntu-latest + needs: ["goreleaser", "create-tag"] + name: Release Notification + steps: + - uses: mattermost/action-mattermost-notify@2.0.0 + with: + MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }} + MATTERMOST_USERNAME: ${{ secrets.MATTERMOST_USERNAME}} + MATTERMOST_ICON_URL: ${{ secrets.MATTERMOST_ICON }} + TEXT: "${{ github.repository }} : Release https://github.com/${{ github.repository }}/releases/tag/${{ needs.create-tag.outputs.new_tag }}"