Skip to content

Commit

Permalink
ci: change all workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Aug 27, 2024
1 parent 68a0ca3 commit 98680b0
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 58 deletions.
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ enable-beta-ecosystems: true
updates:
- package-ecosystem: "gradle"
directory: "/"
target-branch: "dev"
schedule:
interval: "daily"
time: "10:00"
Expand All @@ -19,7 +18,6 @@ updates:

- package-ecosystem: "github-actions"
directory: "/"
target-branch: "dev"
schedule:
interval: "daily"
time: "10:00"
Expand All @@ -31,7 +29,6 @@ updates:

- package-ecosystem: "docker"
directory: "/"
target-branch: "dev"
schedule:
interval: "daily"
time: "10:00"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/check_tokens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: dev

- name: Check tokens and update if necessary
run: |
#!/bin/bash
CRUNCHYROLL_RS_TOKEN=$(curl 'https://raw.githubusercontent.com/crunchy-labs/crunchyroll-rs/master/src/crunchyroll.rs' | grep -oP 'Basic \K[^\\"]*' | head -n 1)
SHIKKANIME_TOKEN=$(curl 'https://raw.githubusercontent.com/Shikkanime/core/dev/src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt' | grep -oP 'Basic \K[^\\"]*' | head -n 1)
SHIKKANIME_TOKEN=$(cat 'src/main/kotlin/fr/shikkanime/wrappers/CrunchyrollWrapper.kt' | grep -oP 'Basic \K[^\\"]*' | head -n 1)
if [ "$CRUNCHYROLL_RS_TOKEN" != "$SHIKKANIME_TOKEN" ]; then
echo "Tokens are different. Updating Shikkanime token..."
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ on:
push:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
schedule:
- cron: '33 14 * * 5'

Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/development_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
pull_request:
types: [opened, synchronize, reopened, edited]
push:
branches: [dev]
branches: [master]

env:
JAVA_VERSION: 21

jobs:
validate-pr-title:
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: PR Conventional Commit Validation
Expand All @@ -29,28 +29,30 @@ jobs:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'corretto'
- name: Analyze push
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
if: github.event_name == 'push'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew sonar --info
- name: Analyse pull request
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'master' && github.actor != 'dependabot[bot]'
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew sonar --info -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} -Dsonar.qualitygate.wait=true
- name: Analyse pull request
if: github.event_name == 'pull_request' && (github.event.pull_request.base.ref == 'master' || github.actor == 'dependabot[bot]')
- name: Build and test
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
run: ./gradlew clean test --info

test-compose:
runs-on: ubuntu-latest
needs: [test]
strategy:
fail-fast: false
matrix:
platform: [linux/amd64, linux/arm64/v8]
runs-on: ubuntu-latest
needs: [test]
platform: [linux/amd64, linux/arm64]
build_version: [slim, full]

steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
Expand All @@ -62,9 +64,11 @@ jobs:
run: gradle clean installDist -x test
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Start services
run: docker compose up -d --build --wait
run: BUILD_VERSION=${{ matrix.build_version }} docker compose up -d --build --wait
- name: Stop services
run: docker compose down
141 changes: 110 additions & 31 deletions .github/workflows/release_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,69 @@
name: Release workflow

on:
push:
branches:
- master
workflow_dispatch: # Allows manual triggering

env:
REGISTRY_IMAGE: registry.shikkanime.fr:5000/shikkanime-core
JAVA_VERSION: 21
REGISTRY_IMAGE: ${{ vars.DOCKERHUB_USERNAME }}/shikkanime-core

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'corretto'
- name: Build and test
run: ./gradlew clean test --info

upgrade-version:
runs-on: ubuntu-latest

outputs:
v-version: ${{ steps.version.outputs.v-version }}

steps:
- uses: actions/checkout@v4

- name: Get next version
uses: reecetech/[email protected]
id: version
with:
scheme: conventional_commits

docker:
runs-on: ubuntu-latest
needs: [test, upgrade-version]
strategy:
fail-fast: false
matrix:
build_version: [slim, full]

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
# Pull the latest commits
- name: Pull latest commits
run: git pull

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: 21
java-version: ${{ env.JAVA_VERSION }}
distribution: 'corretto'

- name: Build
run: gradle clean installDist
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ matrix.build_version }}
type=raw,value=${{ matrix.build_version }}-${{ needs.upgrade-version.outputs.v-version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -33,41 +74,79 @@ jobs:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: registry.shikkanime.fr:5000
username: ziedelth
password: ${{ secrets.REGISTRY_PASSWORD }}
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Update version in build.gradle.kts
run: |
#!/bin/bash
PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1)
# Update the file
sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts
- name: Build
run: gradle clean installDist

- name: Build docker file
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
build-args: BUILD_VERSION=${{ matrix.build_version }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }}
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.build_version }},mode=max
push: true
tags: ${{ env.REGISTRY_IMAGE }}:latest,${{ env.REGISTRY_IMAGE }}:${{ steps.version.outputs.v-version }}
platforms: linux/arm64/v8
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache

- name: Get next version
uses: reecetech/[email protected]
id: version
push-commit:
runs-on: ubuntu-latest
needs: [upgrade-version, docker]
steps:
- uses: actions/checkout@v4
with:
scheme: conventional_commits
persist-credentials: false
fetch-depth: 0

- name: Generate Git Tag
id: generate_tag
- name: Update version in build.gradle.kts
run: |
NEW_TAG="${{ steps.version.outputs.v-version }}"
echo "Generated new tag: $NEW_TAG"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
#!/bin/bash
PROJECT_VERSION=$(cat 'build.gradle.kts' | grep -oP 'version = "\K[^\\"]*' | head -n 1)
# Update the file
sed -i "s|$PROJECT_VERSION|${{ needs.upgrade-version.outputs.v-version }}|g" build.gradle.kts
# Set up Git
git config user.name Ziedelth
git config user.email ${{ secrets.USER_EMAIL }}
# Commit the changes
git add build.gradle.kts
git commit -m "Update version to ${{ needs.upgrade-version.outputs.v-version }}"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.USER_TOKEN }}
branch: ${{ github.ref }}
force: true

push-tag:
runs-on: ubuntu-latest
needs: [upgrade-version, push-commit]

steps:
- uses: actions/checkout@v4

# Pull the latest commits
- name: Pull latest commits
run: git pull

- name: Push Git Tag
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag $NEW_TAG
git push origin $NEW_TAG
- uses: marvinpinto/[email protected]
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
git tag ${{ needs.upgrade-version.outputs.v-version }}
git push origin ${{ needs.upgrade-version.outputs.v-version }}
4 changes: 1 addition & 3 deletions .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ jobs:
- name: Update Gradle Wrapper
uses: gradle-update/[email protected]
with:
reviewers: Ziedelth
base-branch: dev
target-branch: dev
reviewers: Ziedelth
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
ARG JAVA_VERSION=21
ARG PLAYWRIGHT_VERSION=1.46.1
ARG BUILD_VERSION=full

FROM amazoncorretto:${JAVA_VERSION} AS java
FROM mcr.microsoft.com/playwright:v1.46.1-jammy

# Base image for full version
FROM mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-jammy AS full

# Base image for slim version
FROM node:20-bookworm-slim AS slim
ARG PLAYWRIGHT_VERSION
RUN npx -y playwright@${PLAYWRIGHT_VERSION} install --with-deps firefox

# Select the base image based on the build argument
FROM ${BUILD_VERSION}

ARG JAVA_VERSION
COPY --from=java /usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto /usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto

ENV LANG=C.UTF-8 \
JAVA_HOME=/usr/lib/jvm/java-${JAVA_VERSION}-amazon-corretto \
TZ=Europe/Paris \
DEBIAN_FRONTEND=noninteractive
DEBIAN_FRONTEND=noninteractive \
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1

# Install necessary packages and set timezone
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata libopencv-dev fonts-dejavu \
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata libopencv-dev fonts-dejavu curl \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* \
&& ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plugins {
}

group = "fr.shikkanime"
version = "0.0.1"
version = "0.2.15"

application {
mainClass.set("fr.shikkanime.ApplicationKt")
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
shikkanime-db:
image: postgres:16-alpine
Expand All @@ -11,7 +10,10 @@ services:
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres" ]
shikkanime-core:
build: .
build:
context: .
args:
BUILD_VERSION: ${BUILD_VERSION:-full} # Use the environment variable or default to 'full
ports:
- "37100:37100"
restart: on-failure
Expand Down

0 comments on commit 98680b0

Please sign in to comment.