From f731beab23bba3cdc659f2e89c2c9b9c7167d321 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 2 Mar 2024 22:53:40 +0100 Subject: [PATCH] Refactored build workflows --- .gitea/workflows/build-docker.yml | 56 +++++++++++++++++++++++++++++++ .gitea/workflows/build.yml | 43 ++---------------------- 2 files changed, 58 insertions(+), 41 deletions(-) create mode 100644 .gitea/workflows/build-docker.yml diff --git a/.gitea/workflows/build-docker.yml b/.gitea/workflows/build-docker.yml new file mode 100644 index 0000000..85c5519 --- /dev/null +++ b/.gitea/workflows/build-docker.yml @@ -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 \ No newline at end of file diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 85e3da1..8acbe81 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,4 +1,4 @@ -name: SharePulse Build +name: SharePulse build on: push: @@ -41,43 +41,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: jar-artifact - 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 \ No newline at end of file + path: build/libs/*.jar \ No newline at end of file