🚑 Hotfix deployment 5 #60
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upgrade Version and Deploy | |
on: | |
pull_request: | |
types: [ closed ] | |
branches: | |
- 'main' | |
jobs: | |
upgrade-version: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Check out the repo and login with bot account | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Java 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'oracle' | |
java-version: '21.0.3' | |
cache: 'maven' | |
cache-dependency-path: 'server/pom.xml' | |
- name: Setup Git | |
env: | |
GIT_AUTHOR_NAME: ${{ secrets.BOT_USERNAME }} | |
GIT_AUTHOR_EMAIL: "[email protected]" | |
run: | | |
git config --global user.name "${{env.GIT_AUTHOR_NAME}}" | |
git config --global user.email "${{env.GIT_AUTHOR_EMAIL}}" | |
git config push.followTags true | |
git fetch --tags | |
git pull --tags | |
- name: Retrieve versions | |
id: versions | |
shell: bash | |
run: | | |
VERSIONS=$(scripts/retrieve-versions.sh server/pom.xml) | |
NEXT_VERSION=$(echo $VERSIONS | cut -d ':' -f 1) | |
NEW_SNAPSHOT=$(echo $VERSIONS | cut -d ':' -f 2) | |
echo "next_version=$(echo $VERSIONS | cut -d ':' -f 1)" >> $GITHUB_OUTPUT | |
echo "new_snapshot=$(echo $VERSIONS | cut -d ':' -f 2)" >> $GITHUB_OUTPUT | |
- name: Upgrade server pom version to ${{ steps.versions.outputs.next_version }} | |
shell: bash | |
run: | | |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.next_version }} --file server/pom.xml | |
- name: Upgrade version in README.md | |
shell: bash | |
run: | | |
sed -i 's/https:\/\/img.shields.io\/badge\/Version-[0-9]\+\.[0-9]\+\.[0-9]-blue/https:\/\/img.shields.io\/badge\/Version-${{ steps.versions.outputs.next_version }}-blue/g' README.md | |
sed -i 's/image: heavynimbus\/heavy-mock-http-server:[0-9]\+\.[0-9]\+\.[0-9]/image: heavynimbus\/heavy-mock-http-server:${{ steps.versions.outputs.next_version }}/g' README.md | |
- name: Git Add changes | |
run: git add server/pom.xml README.md | |
- name: Git Commit changes | |
run: git commit -m "🚀⬆️ Upgrade version to ${{ steps.versions.outputs.next_version }}" | |
- name: Git Tag ${{ steps.versions.outputs.next_version }} | |
run: git tag ${{ steps.versions.outputs.next_version }} HEAD | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
branch: ${{ github.ref_name }} | |
tags: true | |
- name: Build Docker image ${{ steps.versions.outputs.next_version }} | |
env: | |
NEXT_VERSION: ${{ steps.versions.outputs.next_version }} | |
run: | | |
docker build -t heavy-mock-http-server:$NEXT_VERSION server | |
- name: Push Docker image ${{ steps.versions.outputs.next_version }} | |
env: | |
NEXT_VERSION: ${{ steps.versions.outputs.next_version }} | |
run: | | |
docker tag "heavy-mock-http-server:$NEXT_VERSION" "heavynimbus/heavy-mock-http-server:$NEXT_VERSION" | |
docker push "heavynimbus/heavy-mock-http-server:$NEXT_VERSION" | |
- name: Set snapshot version | |
run: | | |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.new_snapshot }} --file server/pom.xml | |
- name: Git Add changes | |
run: git add server/pom.xml | |
- name: Git Commit changes | |
run: git commit -m "⬆️ Upgrade version to ${{ steps.versions.outputs.new_snapshot }}" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.BOT_GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
branch: ${{ github.ref_name }} | |
tags: true |