105 lines
3.2 KiB
YAML
105 lines
3.2 KiB
YAML
name: SharePulse build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
|
|
jobs:
|
|
build-jar:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v2
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'adopt'
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 'node' # Use latest version
|
|
npm-version: 'latest'
|
|
|
|
- name: Build frontend
|
|
run: |
|
|
cd frontend
|
|
npm install
|
|
npm run build
|
|
cd ..
|
|
|
|
- name: Grant execute permission for gradlew
|
|
run: chmod +x ./gradlew
|
|
|
|
- name: Build .jar with Gradle
|
|
run: ./gradlew clean bootJar
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: jar-artifact
|
|
path: build/libs/*.jar
|
|
|
|
build-docker-image:
|
|
runs-on: ubuntu-22.04
|
|
needs: build-jar
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Extract tag name
|
|
run: |
|
|
git fetch --tags
|
|
GIT_TAG=$(git tag --points-at HEAD)
|
|
if [[ "$GIT_TAG" == v* ]]; then
|
|
VERSION=${GIT_TAG#v}
|
|
echo "Version tag found. Initializing docker image build for version: $VERSION"
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
else
|
|
echo "No version tag found. Skipping subsequent steps. (Version tag format: vX.X.X)"
|
|
echo "SKIP_SUBSEQUENT_STEPS=true" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Initialize Docker runtime
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
run: |
|
|
apt-get update
|
|
apt-get install ca-certificates curl gnupg lsb-release -y
|
|
install -m 0755 -d /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
|
echo \
|
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
$(lsb_release -cs) stable" | \
|
|
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
apt-get update
|
|
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin -y
|
|
|
|
- name: Download Artifact
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: jar-artifact
|
|
path: build/libs
|
|
|
|
- name: Build Docker Image
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
run: docker build . -t walzen665/sharepulse:$VERSION
|
|
|
|
- name: Tag Docker image
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
run: docker tag walzen665/sharepulse:latest git.walzen665.de/walzen665/sharepulse:$VERSION
|
|
|
|
- name: Log in to Gitea Docker Registry
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
run: echo ${{ secrets.GITEAREGISTRYTOKEN }} | docker login -u ${{ secrets.GITEAREGISTRYUSERNAME }} --password-stdin https://git.walzen665.de
|
|
|
|
- name: Push Docker Image to Gitea
|
|
if: env.SKIP_SUBSEQUENT_STEPS != 'true'
|
|
run: docker push git.walzen665.de/walzen665/sharepulse:$VERSION
|
|
|
|
|