sync-main~tuanngocptn #43
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: VTD BE PPAP | |
on: | |
repository_dispatch: | |
types: | |
- vtd-trigger | |
- sync-** | |
env: | |
# TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
# TELEGRAM_GROUP_ID: ${{ vars.TELEGRAM_GROUP_ID}} | |
# TELEGRAM_TOPIC_ID: ${{ vars.TELEGRAM_TOPIC_ID}} | |
REF_NAME: ${{ github.event.client_payload.ref_name}} | |
TRIGGERING_ACTOR: ${{ github.event.client_payload.triggering_actor}} | |
jobs: | |
build-and-check: | |
name: ${{ matrix.name }} | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- name: Gift service | |
service: gift | |
package: loyalty | |
- name: Order service | |
service: order | |
package: order | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ secrets.VTD_REPOSITORY_SOURCE }} | |
token: ${{ secrets.GH_PAT }} | |
ref: ${{ env.REF_NAME }} | |
path: source | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ secrets.VTD_REPOSITORY_TARGET }}${{ matrix.service }} | |
token: ${{ secrets.GH_PAT }} | |
ref: main | |
path: target | |
- name: Switch branch | |
working-directory: target | |
run: | | |
git fetch --all | |
git switch -c ${{ env.REF_NAME }} | |
git pull origin ${{ env.REF_NAME }} | |
- name: Setup java 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "21" | |
- name: Remove the rest | |
run: | | |
mkdir backup | |
mv -v source/${{ secrets.SERVICE_PACKAGE_PATH }}/* backup | |
mv backup/main source/${{ secrets.SERVICE_PACKAGE_PATH }}/ | |
mv backup/Application.java source/${{ secrets.SERVICE_PACKAGE_PATH }}/ | |
mv backup/ConfigProperties.java source/${{ secrets.SERVICE_PACKAGE_PATH }}/ | |
mv backup/${{ matrix.package }} source/${{ secrets.SERVICE_PACKAGE_PATH }}/ | |
- name: Build and package project | |
working-directory: source | |
run: | | |
echo "${{ secrets.ENV_PROPERTIES }}" > src/main/resources/application-dev-base64.properties | |
cat src/main/resources/application-dev-base64.properties | base64 -d > src/main/resources/application-dev.properties | |
mvn -f pom.xml clean install package -q | |
- name: Move code to the result | |
run: | | |
mkdir result | |
mv target/.git result/ | |
rm -rf source/.git | |
shopt -s dotglob | |
mv -v source/* result/ | |
- name: Push result | |
working-directory: result | |
run: | | |
git config user.name "GitHub Actions" --local | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" --local | |
git add -A | |
git diff-index --quiet HEAD || git commit -m ':white_check_mark: update code' | |
git push origin ${{ env.REF_NAME }} |