160 lines
4.8 KiB
YAML
160 lines
4.8 KiB
YAML
name: Pull Request Pipeline
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
if: false
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install jq
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y jq
|
|
|
|
- name: Install Flutter (wget)
|
|
run: |
|
|
wget --quiet https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.38.2-stable.tar.xz
|
|
tar xf flutter_linux_3.38.2-stable.tar.xz
|
|
# Set Git safe directory for Flutter path
|
|
git config --global --add safe.directory "$(pwd)/flutter"
|
|
# Set Flutter path
|
|
echo "$(pwd)/flutter/bin" >> $GITEA_PATH
|
|
|
|
- name: Get dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Analyze Formatting
|
|
run: flutter analyze lib test
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
if: false
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y jq
|
|
|
|
- name: Install Flutter (wget)
|
|
run: |
|
|
wget --quiet https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.38.2-stable.tar.xz
|
|
tar xf flutter_linux_3.38.2-stable.tar.xz
|
|
# Set Git safe directory for Flutter path
|
|
git config --global --add safe.directory "$(pwd)/flutter"
|
|
# Set Flutter path
|
|
echo "$(pwd)/flutter/bin" >> $GITHUB_PATH
|
|
|
|
- name: Get dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Run tests
|
|
run: flutter test
|
|
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
if: false
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y jq
|
|
|
|
- name: Install Flutter (wget)
|
|
run: |
|
|
wget --progress=dot:giga https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.38.2-stable.tar.xz
|
|
tar xf flutter_linux_3.38.2-stable.tar.xz
|
|
# Set Git safe directory for Flutter path
|
|
git config --global --add safe.directory "$(pwd)/flutter"
|
|
# Set Flutter path
|
|
echo "$(pwd)/flutter/bin" >> $GITHUB_PATH
|
|
|
|
- name: Get dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Check code format
|
|
id: check_format
|
|
continue-on-error: true
|
|
run: flutter analyze lib test
|
|
|
|
- name: Format code
|
|
if: steps.check_format.outcome == 'failure'
|
|
run: |
|
|
git fetch origin ${{ gitea.head_ref }}
|
|
git checkout ${{ gitea.head_ref }}
|
|
|
|
dart fix --apply lib
|
|
dart fix --apply test
|
|
|
|
if [ -n "$(git status --porcelain lib test)" ]; then
|
|
git config --global user.name "Gitea Actions [bot]"
|
|
git config --global user.email "actions@gitea.com"
|
|
git add lib test
|
|
git commit -m "Auto-format code"
|
|
git push
|
|
# Alt: git push https://oauth2:${{ secrets.BOT_TOKEN }}@git.yannick-weigert.de/liquid-development/game-tracker.git HEAD:${{ gitea.head_ref }}
|
|
else
|
|
echo "No changes to commit"
|
|
fi
|
|
|
|
- name: Verify format
|
|
run: flutter analyze lib test
|
|
|
|
|
|
update-version:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Test Token
|
|
run: |
|
|
echo "Testing token permissions..."
|
|
|
|
# Token-Format prüfen
|
|
if [ -z "${{ secrets.BOT_TOKEN }}" ]; then
|
|
echo "❌ BOT_TOKEN ist nicht gesetzt"
|
|
exit 1
|
|
fi
|
|
|
|
# API-Call zum Prüfen der Token-Berechtigungen
|
|
curl -f -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
|
|
https://git.yannick-weigert.de/api/v1/user
|
|
|
|
# Repository-Zugriff testen
|
|
curl -f -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
|
|
https://git.yannick-weigert.de/api/v1/repos/liquid-development/game-tracker
|
|
|
|
echo "✅ Token ist gültig"
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Update version
|
|
uses: https://github.com/stikkyapp/update-pubspec-version@v2
|
|
with:
|
|
strategy: 'patch'
|
|
path: './pubspec.yaml'
|
|
|
|
- name: Commit version update
|
|
run: |
|
|
git fetch origin ${{ gitea.head_ref }}
|
|
git checkout ${{ gitea.head_ref }}
|
|
|
|
git config --global user.name "Gitea Actions [bot]"
|
|
git config --global user.email "actions@gitea.com"
|
|
git add pubspec.yaml
|
|
git commit -m "Updated version number"
|
|
# git push
|
|
git push https://oauth2:${{ secrets.BOT_TOKEN }}@git.yannick-weigert.de/liquid-development/game-tracker.git HEAD:${{ gitea.head_ref }}
|
|
|