From 659b610f5d38cf07778e489296b95720daaa5d93 Mon Sep 17 00:00:00 2001 From: amithkoujalgi Date: Sat, 9 Nov 2024 00:05:52 +0530 Subject: [PATCH] Updated GitHub Actions Updated GitHub Actions --- .github/workflows/push-docker-image.yml | 47 ------------- .github/workflows/release-artifacts.yml | 87 +++++++++++++++++++++++++ .github/workflows/release-jar.yml | 45 ------------- 3 files changed, 87 insertions(+), 92 deletions(-) delete mode 100644 .github/workflows/push-docker-image.yml create mode 100644 .github/workflows/release-artifacts.yml delete mode 100644 .github/workflows/release-jar.yml diff --git a/.github/workflows/push-docker-image.yml b/.github/workflows/push-docker-image.yml deleted file mode 100644 index 64c5ad5..0000000 --- a/.github/workflows/push-docker-image.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: CI - Build and Push Docker Image - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - env: - CONTEXT_SUBDIR: . - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Build with Maven - run: mvn -B -Drevision=0.0.1 clean package --file pom.xml -Pproduction - # run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction - - - name: Log in to Docker Hub - run: docker login -u amithkoujalgi -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - push: true - tags: amithkoujalgi/ollama4j-web-ui:0.0.1 \ No newline at end of file diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml new file mode 100644 index 0000000..d28b4f9 --- /dev/null +++ b/.github/workflows/release-artifacts.yml @@ -0,0 +1,87 @@ +name: Release Artifacts + +on: + push: + tags: + - '**' + +permissions: + contents: read + id-token: write + packages: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-publish-jar: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + repository-projects: write + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build with Maven + run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction + + - name: Release Assets + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: startsWith(github.ref, 'refs/tags/') + with: + files: target/*.jar + + build-and-push-docker-image: + runs-on: ubuntu-latest + + needs: + - build-and-publish-jar + + permissions: + contents: write + pull-requests: write + repository-projects: write + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build with Maven + run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction + + - name: Log in to Docker Hub + run: docker login -u amithkoujalgi -p ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + if: startsWith(github.ref, 'refs/tags/') + with: + context: . + file: Dockerfile + push: true + tags: amithkoujalgi/ollama4j-web-ui:${{ env.RELEASE_VERSION }} \ No newline at end of file diff --git a/.github/workflows/release-jar.yml b/.github/workflows/release-jar.yml deleted file mode 100644 index 9443cd7..0000000 --- a/.github/workflows/release-jar.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Release JAR - -on: - push: - tags: - - '**' - -permissions: - contents: read - id-token: write - packages: write - -jobs: - build: - - runs-on: ubuntu-latest - - permissions: - contents: write - pull-requests: write - repository-projects: write - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Build with Maven - run: mvn -B -Drevision=${{ env.RELEASE_VERSION }} clean package --file pom.xml -Pproduction - - - name: Release Assets - uses: softprops/action-gh-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: startsWith(github.ref, 'refs/tags/') - with: - files: target/*.jar