Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: 2
updates:
# Gradle dependencies
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 5
reviewers:
- "drag0sd0g"
labels:
- "dependencies"
- "automated"
commit-message:
prefix: "chore(deps)"
include: "scope"

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 5
reviewers:
- "drag0sd0g"
labels:
- "dependencies"
- "github-actions"
commit-message:
prefix: "chore(deps)"
include: "scope"

# Docker dependencies
- package-ecosystem: "docker"
directory: "/file-storage-server"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 5
reviewers:
- "drag0sd0g"
labels:
- "dependencies"
- "docker"
commit-message:
prefix: "chore(deps)"
include: "scope"

- package-ecosystem: "docker"
directory: "/file-storage-client"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 5
reviewers:
- "drag0sd0g"
labels:
- "dependencies"
- "docker"
commit-message:
prefix: "chore(deps)"
include: "scope"
58 changes: 58 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CodeQL Security Scan

on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
schedule:
- cron: '0 0 * * 1' # Run weekly on Mondays
workflow_run:
workflows: ["Clean Build"]
types:
- completed

jobs:
analyze:
name: Analyze Code
runs-on: ubuntu-latest
# Only run if the build workflow succeeded or if triggered by schedule/manual
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality

- name: Build with Gradle
uses: gradle/gradle-build-action@v3
with:
arguments: clean build -x test -x checkstyleMain -x checkstyleTest -x pmdMain -x pmdTest -x spotbugsMain -x spotbugsTest

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
97 changes: 97 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Docker Build and Publish

on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches:
- main
- master
workflow_run:
workflows: ["CodeQL Security Scan"]
types:
- completed

env:
REGISTRY: ghcr.io
SERVER_IMAGE_NAME: ${{ github.repository }}/server
CLIENT_IMAGE_NAME: ${{ github.repository }}/client

jobs:
build-and-push:
runs-on: ubuntu-latest
# Run on: manual triggers, successful CodeQL completion, or tag pushes
# workflow_run handles PR/push events after CodeQL succeeds
# Tag pushes trigger directly for releases
if: |
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Server
id: meta-server
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.SERVER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Extract metadata for Client
id: meta-client
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.CLIENT_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha

- name: Build and push Server image
uses: docker/build-push-action@v5
with:
context: .
file: ./file-storage-server/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-server.outputs.tags }}
labels: ${{ steps.meta-server.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push Client image
uses: docker/build-push-action@v5
with:
context: .
file: ./file-storage-client/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-client.outputs.tags }}
labels: ${{ steps.meta-client.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
63 changes: 56 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,68 @@
name: Clean Build

on: [push]
on:
push:
branches:
- '**'
pull_request:
branches:
- main
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- name: Clean Build
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
cache: 'gradle'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and Test
uses: gradle/gradle-build-action@v3
with:
arguments: clean build distClient distServer

- name: Run Static Analysis
uses: gradle/gradle-build-action@v3
with:
arguments: checkstyleMain checkstyleTest pmdMain pmdTest spotbugsMain spotbugsTest
continue-on-error: true

- name: Upload Test Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
path: |
**/build/reports/tests/
**/build/jacocoHtml/
retention-days: 7

- name: Upload Static Analysis Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: static-analysis-reports
path: |
**/build/reports/checkstyle/
**/build/reports/pmd/
**/build/reports/spotbugs/
retention-days: 7

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
build/fsclient/*.jar
build/fsserver/*.jar
retention-days: 30
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Release and Tag

on:
push:
branches:
- main
- master
paths-ignore:
- '**.md'
- '.github/**'
- '!.github/workflows/release.yml'

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Build with Gradle
uses: gradle/gradle-build-action@v3
with:
arguments: clean build distClient distServer -x checkstyleMain -x checkstyleTest -x pmdMain -x pmdTest -x spotbugsMain -x spotbugsTest

- name: Get version from build.gradle
id: get_version
run: |
VERSION=$(grep "version" build.gradle | head -1 | awk -F'"' '{print $2}')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}-${{ github.run_number }}
release_name: Release v${{ steps.get_version.outputs.version }}-${{ github.run_number }}
body: |
Automated release from commit ${{ github.sha }}

## Changes
See commit history for details.

## Artifacts
- file-storage-server-${{ steps.get_version.outputs.version }}.jar
- file-storage-client-${{ steps.get_version.outputs.version }}.jar
draft: false
prerelease: false

- name: Upload Server Jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/fsserver/file-storage-server-${{ steps.get_version.outputs.version }}.jar
asset_name: file-storage-server-${{ steps.get_version.outputs.version }}.jar
asset_content_type: application/java-archive

- name: Upload Client Jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/fsclient/file-storage-client-${{ steps.get_version.outputs.version }}.jar
asset_name: file-storage-client-${{ steps.get_version.outputs.version }}.jar
asset_content_type: application/java-archive
Loading
Loading