Compare commits
2 commits
3664d06d17
...
8a80e58e54
Author | SHA1 | Date | |
---|---|---|---|
8a80e58e54 | |||
365a0ae602 |
9 changed files with 312 additions and 0 deletions
32
.forgejo/ISSUE_TEMPLATE/bug.md
Normal file
32
.forgejo/ISSUE_TEMPLATE/bug.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
name: Bug
|
||||||
|
about: Create a bug report to help us improve forgejo-guardian
|
||||||
|
title: "..."
|
||||||
|
labels: ["Kind/Bug"]
|
||||||
|
assignees: ""
|
||||||
|
---
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
- [ ] I added a descriptive title to this issue
|
||||||
|
- [ ] I have searched Google for similar issues and couldn't find anything
|
||||||
|
- [ ] I have read [the README](https://git.4rs.nl/awiteb/forgejo-guardian/src/branch/master/README.md) and still think this is a bug
|
||||||
|
|
||||||
|
## Version
|
||||||
|
|
||||||
|
<!-- Report for the bug only if it's present in the latest version of forgejo-guardian.
|
||||||
|
If you are not using the latest version, please update and check if the bug is still present. -->
|
||||||
|
|
||||||
|
forgejo-guardian version: `...`
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
<!-- A clear and concise description of what the bug is. -->
|
||||||
|
|
||||||
|
## Expected behavior
|
||||||
|
|
||||||
|
<!-- A clear and concise description of what you expected to happen. -->
|
||||||
|
|
||||||
|
## Actual behavior
|
||||||
|
|
||||||
|
<!-- A clear and concise description of what happens. -->
|
11
.forgejo/ISSUE_TEMPLATE/feature_request.md
Normal file
11
.forgejo/ISSUE_TEMPLATE/feature_request.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for forgejo-guardian
|
||||||
|
title: "..."
|
||||||
|
labels: ["Kind/Feature"]
|
||||||
|
assignees: ""
|
||||||
|
---
|
||||||
|
|
||||||
|
## Feature description
|
||||||
|
|
||||||
|
<!-- A clear and concise description of what the feature is, and why you think it is needed. -->
|
19
.forgejo/pull_request_template.md
Normal file
19
.forgejo/pull_request_template.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
<!-- Please provide a brief description of the changes made in this PR -->
|
||||||
|
|
||||||
|
### Related issue
|
||||||
|
|
||||||
|
<!-- Mention any relevant issues like #123 -->
|
||||||
|
|
||||||
|
|
||||||
|
## Changes
|
||||||
|
|
||||||
|
<!-- Please provide some more detail regarding the changes.
|
||||||
|
Add any additional information, configuration, or data that might be necessary for the review
|
||||||
|
Mention the type of each change. i.e. `Addition`, `Bug Fix`, `Documentation`, etc... -->
|
||||||
|
|
||||||
|
|
||||||
|
## Checklist
|
||||||
|
- [ ] Added tests if applicable (for new features/regression/etc...)
|
||||||
|
- [ ] Documentation
|
106
.forgejo/workflows/cd.yml
Normal file
106
.forgejo/workflows/cd.yml
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
name: CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v[0-9]+.[0-9]+.[0-9]+
|
||||||
|
- v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-assets:
|
||||||
|
runs-on: debian
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- x86_64-unknown-linux-gnu
|
||||||
|
- x86_64-unknown-linux-musl
|
||||||
|
- aarch64-unknown-linux-gnu
|
||||||
|
- aarch64-unknown-linux-musl
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
fetch-depth: 1
|
||||||
|
- uses: https://codeberg.org/awiteb/rust-action@v1.74
|
||||||
|
- name: Install musl-tools
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y musl-tools
|
||||||
|
if: ${{ contains(matrix.target, 'musl') }}
|
||||||
|
- name: Install gcc-aarch64-linux-gnu linker
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gcc-aarch64-linux-gnu
|
||||||
|
if: ${{ contains(matrix.target, 'aarch64') }}
|
||||||
|
- name: Preparing the environment
|
||||||
|
run: |
|
||||||
|
BIN_NAME="$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)"
|
||||||
|
echo "BIN_NAME=$BIN_NAME" >> $GITHUB_ENV
|
||||||
|
mkdir -p release-dir
|
||||||
|
mkdir -p .cargo
|
||||||
|
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' > .cargo/config.toml
|
||||||
|
echo 'target.aarch64-unknown-linux-musl.linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
|
||||||
|
|
||||||
|
- name: Install the target
|
||||||
|
run: rustup target install ${{ matrix.target }}
|
||||||
|
|
||||||
|
- name: Build the asset
|
||||||
|
run: |
|
||||||
|
TARGET=$(echo ${{ matrix.target }} | sed -e 's/-unknown//g' | sed -e 's/-pc//g')
|
||||||
|
APP_NAME="$BIN_NAME-$GITHUB_REF_NAME-$TARGET"
|
||||||
|
cargo clean
|
||||||
|
cargo build --release --target ${{ matrix.target }}
|
||||||
|
cp target/${{ matrix.target }}/release/$BIN_NAME release-dir/$APP_NAME
|
||||||
|
cd release-dir
|
||||||
|
test -f $APP_NAME && sha256sum $APP_NAME > $APP_NAME.sha256
|
||||||
|
|
||||||
|
# Upload the artifact, so it can be used in the release step
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.GITHUB_SHA }}-${{ env.GITHUB_RUN_NUMBER }}
|
||||||
|
path: ${{ env.GITHUB_WORKSPACE }}/release-dir
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: build-assets
|
||||||
|
runs-on: debian
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ${{ env.GITHUB_SHA }}-${{ env.GITHUB_RUN_NUMBER }}
|
||||||
|
path: ${{ env.GITHUB_WORKSPACE }}/release-dir
|
||||||
|
- name: Install git-cliff
|
||||||
|
run: |
|
||||||
|
version="2.4.0"
|
||||||
|
wget "https://github.com/orhun/git-cliff/releases/download/v$version/git-cliff-$version-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
tar -xvzf git-cliff-*.tar.gz
|
||||||
|
mv "git-cliff-$version/git-cliff" /usr/local/bin
|
||||||
|
rm -fr git-cliff-*
|
||||||
|
- name: Write changelog
|
||||||
|
run: |
|
||||||
|
git config user.name forgejo-actions
|
||||||
|
git config user.email forgejo-actions@noreply.localhost
|
||||||
|
echo 'TAG_CHANGELOG=$(if [[ $(git tag --sort=committerdate | tail -n 1) == *"-rc"* ]]; then git-cliff --strip all $(git tag --sort=committerdate | tail -n 2 | sed ":a; N; $!ba; s/\n/../g") | sed "s/## unreleased.*$//g"; else git-cliff -l --strip all | sed "s/^## \[.*$//g";fi)' | sed "s/\"/'/g" >> $GITHUB_ENV
|
||||||
|
if [[ $(git tag --sort=creatordate | tail -n 1) != *'-rc'* ]]; then
|
||||||
|
echo "The latest tag is not a release candidate, updating changelog for $GITHUB_REF_NAME"
|
||||||
|
git-cliff > CHANGELOG.md
|
||||||
|
git add CHANGELOG.md
|
||||||
|
git commit -m "Update changelog for $GITHUB_REF_NAME"
|
||||||
|
git push
|
||||||
|
echo "Changelog updated"
|
||||||
|
else
|
||||||
|
echo "The latest tag is a release candidate, not updating changelog"
|
||||||
|
fi
|
||||||
|
- name: Create Release
|
||||||
|
uses: actions/forgejo-release@v1
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
url: https://git.4rs.nl
|
||||||
|
token: ${{ env.GITHUB_TOKEN }}
|
||||||
|
release-dir: release-dir
|
||||||
|
release-notes: ${{ env.TAG_CHANGELOG }}
|
||||||
|
prerelease: ${{ contains(env.GITHUB_REF_NAME, '-rc') }}
|
36
.forgejo/workflows/changelog.yml
Normal file
36
.forgejo/workflows/changelog.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
name: Write changelog
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
write-changelog:
|
||||||
|
runs-on: debian
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
- name: Install git-cliff
|
||||||
|
run: |
|
||||||
|
version="2.4.0"
|
||||||
|
wget "https://github.com/orhun/git-cliff/releases/download/v$version/git-cliff-$version-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
|
tar -xvzf git-cliff-*.tar.gz
|
||||||
|
mv "git-cliff-$version/git-cliff" /usr/local/bin
|
||||||
|
rm -fr git-cliff-*
|
||||||
|
- name: Write changelog
|
||||||
|
run: |
|
||||||
|
git config user.name forgejo-actions
|
||||||
|
git config user.email forgejo-actions@noreply.localhost
|
||||||
|
git-cliff > CHANGELOG.md
|
||||||
|
if [[ $(git status | grep --extended-regexp '^\s+modified:\s+CHANGELOG.md$') ]]; then
|
||||||
|
git add CHANGELOG.md
|
||||||
|
git commit -m "chore(changelog): Update changelog"
|
||||||
|
git push
|
||||||
|
echo "Changelog updated"
|
||||||
|
else
|
||||||
|
echo "No changes to changelog"
|
||||||
|
fi
|
25
.forgejo/workflows/ci.yml
Normal file
25
.forgejo/workflows/ci.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
name: Rust CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
rust_ci:
|
||||||
|
name: Rust CI
|
||||||
|
runs-on: debian
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: https://codeberg.org/awiteb/rust-action@v1.81
|
||||||
|
- name: Check MSRV
|
||||||
|
run: cargo +1.81 build
|
||||||
|
- name: Build the source code
|
||||||
|
run: cargo build
|
||||||
|
- name: Check the code format
|
||||||
|
run: cargo fmt -- --check
|
||||||
|
- name: Run cargo-check
|
||||||
|
run: cargo check
|
||||||
|
- name: Run cargo-clippy
|
||||||
|
run: cargo clippy -- -D warnings
|
29
.forgejo/workflows/dco_checker.yml
Normal file
29
.forgejo/workflows/dco_checker.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: DCO checker
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: DCO checker
|
||||||
|
runs-on: debian
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: DCO checker
|
||||||
|
run: |
|
||||||
|
commits=$(git rev-list origin/master..HEAD)
|
||||||
|
for commit in $commits; do
|
||||||
|
commit_subject=$(git show --quiet --format=%s $commit)
|
||||||
|
commit_sha=$(echo $commit | cut -c1-10)
|
||||||
|
echo "Checking commit $commit_sha \"$commit_subject\""
|
||||||
|
if ! git show --quiet --format=%B $commit | grep -q "Signed-off-by:"; then
|
||||||
|
author=$(git show --quiet --format=%an $commit)
|
||||||
|
echo "Commit $commit by $author is missing the 'Signed-off-by:' line"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "All commits have the 'Signed-off-by:' line."
|
34
.github/workflows/auto_close_pr.yml
vendored
Normal file
34
.github/workflows/auto_close_pr.yml
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: Auto close PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
close_pr:
|
||||||
|
name: Auto close PR
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Send close comment
|
||||||
|
run: |
|
||||||
|
curl -L \
|
||||||
|
-X POST \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer $PAT" \
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/comments \
|
||||||
|
-d '{"body":"${{ env.BODY }}"}'
|
||||||
|
env:
|
||||||
|
PAT: ${{ secrets.PAT }}
|
||||||
|
BODY: This repository is mirror only and you cannot create a pull request for it. Please open your PR in https://git.4rs.nl/awiteb/forgejo-guardian
|
||||||
|
- name: Close the PR
|
||||||
|
run: |
|
||||||
|
curl -L \
|
||||||
|
-X PATCH \
|
||||||
|
-H "Accept: application/vnd.github+json" \
|
||||||
|
-H "Authorization: Bearer $PAT" \
|
||||||
|
-H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }} \
|
||||||
|
-d '{"state":"closed"}'
|
||||||
|
env:
|
||||||
|
PAT: ${{ secrets.PAT }}
|
20
CHANGELOG.md
Normal file
20
CHANGELOG.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## unreleased
|
||||||
|
### Added
|
||||||
|
- Add Russian language ([`8dc8c0d`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/8dc8c0d2315d7d47f6f2605fcdfd62499a4c4460))
|
||||||
|
- Add telegram bot to the config ([`68cd88e`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/68cd88e96af0cd92c10e30ec9675f003c89c436f))
|
||||||
|
- Checks only new users configuration ([`f68ce0c`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/f68ce0c5bd86e1a637736219f0e952831fe8cc7b))
|
||||||
|
- Dry run mode ([`c3972b3`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/c3972b356642c3977b4a2477e4a5f1acd3db868f))
|
||||||
|
- Initialize `forgejo-guardian` ([`d12c45e`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/d12c45ed637b0ba1e42b73fe46520e65b0d0dfd9))
|
||||||
|
- Notification when users are banned ([`6070ca0`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/6070ca035cb6f18b18a2e467240c06d6df3c6092))
|
||||||
|
- Send sus alert via telegram ([`5bb6114`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/5bb6114aa77e629fcc0c12177b401ac7ab287db2))
|
||||||
|
### Fixed
|
||||||
|
- Respect `telegram.ban_alert` configuration ([`9b533e7`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/9b533e7ea37741808e63500e6f7b3273cfcb8e5a))
|
||||||
|
- Split the haystack lines ([`8803305`](https://git.4rs.nl/awiteb/forgejo-guardian/commit/880330576dffa09909beee8c1ec3570f40915adc))
|
||||||
|
|
||||||
|
This changelog was generated by [git-cliff](https://github.com/orhun/git-cliff)
|
Loading…
Reference in a new issue