Skip to content

Feature/MIDAZ-358

Feature/MIDAZ-358 #151

name: Update Envs Version With TAG Release
on:
pull_request:
branches:
- develop
types:
- opened
- edited
- synchronize
- reopened
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
update-env-release:
name: Run update VERSION in every ENV on components
runs-on: ubuntu-24.04
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
private-key: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_PRIVATE_KEY }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
id: import_gpg
with:
gpg_private_key: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY }}
passphrase: ${{ secrets.LERIAN_CI_CD_USER_GPG_KEY_PASSWORD }}
git_committer_name: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
git_committer_email: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Install GitHub CLI
run: sudo apt-get install -y gh
- name: Fetch Latest Release
id: latest_release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
RAW_RELEASE=$(gh release list --repo $GITHUB_REPOSITORY --limit 1 --json tagName --jq '.[0].tagName')
FORMATTED_RELEASE=$(echo "$RAW_RELEASE" | sed -E 's/-[a-zA-Z0-9.]+//')
echo "Raw release: $RAW_RELEASE"
echo "Formatted release: $FORMATTED_RELEASE"
echo "::set-output name=tag::$FORMATTED_RELEASE"
- name: Fetch Env Release
id: env_release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION=$(grep '^VERSION=' ./components/ledger/.env.example | cut -d '=' -f2)
echo "LEDGER version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Update AUDIT Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/audit/.env.example
- name: Update LEDGER Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/ledger/.env.example
- name: Update TRANSACTION Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/transaction/.env.example
- name: Update MDZ Env
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
sed -i "s/^VERSION=.*/VERSION=${{ steps.latest_release.outputs.tag }}/" ./components/mdz/.env.example
- name: Git Diff
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
run: |
git diff
- name: Commit Changes
if: steps.latest_release.outputs.tag != steps.env_release.outputs.version
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GIT_AUTHOR_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.LERIAN_CI_CD_USER_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.LERIAN_CI_CD_USER_EMAIL }}
run: |
git add .
git commit -m "chore(release): update version in .env.example to ${{ steps.latest_release.outputs.tag }}"
git push origin ${{ github.head_ref }}