hotfix/deploy #62
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.BOT_GITHUB_TOKEN }} | |
persist-credentials: true | |
fetch-tags: true | |
fetch-depth: false | |
- 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: 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 |