Refactored build workflows

This commit is contained in:
Max W. 2024-03-02 22:53:40 +01:00
parent f69415141c
commit f731beab23
2 changed files with 58 additions and 41 deletions

View File

@ -0,0 +1,56 @@
name: SharePulse docker image build
on:
push:
tags:
- 'v*'
jobs:
build-docker-image:
needs: build-jar
runs-on: ubuntu-22.04
steps:
- name: Extract tag name
id: get_tag
run: |
TAG_NAME=$(echo $GITEA_REF | sed -n 's/refs\/tags\/v\([0-9.]*\)/\1/p')
if [ -z "$TAG_NAME" ]; then
echo "Tag does not start with 'v', skipping..."
exit 78 # Exiting with specific status to mark job as skipped
fi
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Initialize Docker runtime
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: Checkout
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: jar-artifact
path: build/libs
- name: Build Docker Image
run: docker build . -t walzen665/sharepulse:latest
- name: Tag Docker image
run: docker tag walzen665/sharepulse:latest git.walzen665.de/walzen665/sharepulse:latest
- name: Log in to Gitea Docker Registry
run: echo ${{ secrets.GITEAREGISTRYTOKEN }} | docker login -u ${{ secrets.GITEAREGISTRYUSERNAME }} --password-stdin https://git.walzen665.de
- name: Push Docker Image to Gitea
run: docker push git.walzen665.de/walzen665/sharepulse:latest

View File

@ -1,4 +1,4 @@
name: SharePulse Build name: SharePulse build
on: on:
push: push:
@ -42,42 +42,3 @@ jobs:
with: with:
name: jar-artifact name: jar-artifact
path: build/libs/*.jar path: build/libs/*.jar
build-docker-image:
needs: build-jar
runs-on: ubuntu-22.04
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Initialize Docker runtime
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: Checkout
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: jar-artifact
path: build/libs
- name: Build Docker Image
run: docker build . -t walzen665/sharepulse:latest
- name: Tag Docker image
run: docker tag walzen665/sharepulse:latest git.walzen665.de/walzen665/sharepulse:latest
- name: Log in to Gitea Docker Registry
run: echo ${{ secrets.GITEAREGISTRYTOKEN }} | docker login -u ${{ secrets.GITEAREGISTRYUSERNAME }} --password-stdin https://git.walzen665.de
- name: Push Docker Image to Gitea
run: docker push git.walzen665.de/walzen665/sharepulse:latest