Skip to content

fix: update prod properties (#5) #5

fix: update prod properties (#5)

fix: update prod properties (#5) #5

name: Commit to Main Pipeline
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build_test_release:
runs-on: ubuntu-22.04
env:
SPRING_PROFILES_ACTIVE: prod
BP_SPRING_PROFILES_ACTIVE: prod
outputs:
new-version: ${{ (steps.version_increment.outputs.bump != 'none' && steps.calculate_version.outputs.new_version) || '' }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Get merged pull request
id: get_merged_pr
uses: actions-ecosystem/action-get-merged-pull-request@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Determine version increment
id: version_increment
run: |
LABELS="${{ steps.get_merged_pr.outputs.labels }}"
case "$LABELS" in
*major*) BUMP="major" ;;
*minor*) BUMP="minor" ;;
*patch*) BUMP="patch" ;;
*) BUMP="none"
esac
echo "bump=$BUMP" >> $GITHUB_OUTPUT
- name: Calculate new version (Semantic Versioning)
id: calculate_version
if: steps.version_increment.outputs.bump != 'none'
run: |
LATEST_TAG=$(git tag --sort=-version:refname | head -n 1)
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="0.0.0"
fi
IFS='.' read -r major minor patch <<< "$LATEST_TAG"
BUMP=${{ steps.version_increment.outputs.bump }}
if [ "$BUMP" = "major" ]; then
major=$((major + 1))
minor=0
patch=0
elif [ "$BUMP" = "minor" ]; then
minor=$((minor + 1))
patch=0
elif [ "$BUMP" = "patch" ]; then
patch=$((patch + 1))
fi
echo "new_version=${major}.${minor}.${patch}" >> $GITHUB_OUTPUT
- name: Build & Test
run: ./gradlew clean build
- name: Build & push docker image
if: steps.version_increment.outputs.bump != 'none'
env:
DOCKER_IMAGE_VERSION: "${{ steps.calculate_version.outputs.new_version }}"
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
run: ./gradlew bootBuildImage
- name: Create GitHub Release
if: steps.version_increment.outputs.bump != 'none'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.calculate_version.outputs.new_version }}"
git push origin "${{ steps.calculate_version.outputs.new_version }}"
update-cd-repo:
uses: AutoInvestor/infra-gitops/.github/workflows/update-version.yml@main
needs: build_test_release
if: needs.build_test_release.outputs.new-version != ''
with:
image: autoinvestor-core
version: ${{ needs.build_test_release.outputs.new-version }}
secrets: inherit