Merge pull request #3389 from dzhw/dev-2024-2-2 #741
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- development | |
- test | |
- master | |
tags-ignore: | |
- v* | |
paths-ignore: | |
- 'docs/**' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get build commit hash | |
run: | | |
export BUILD_COMMIT_HASH=$(git rev-parse HEAD) | |
echo $BUILD_COMMIT_HASH | |
sed -i "s/\"buildHash\": \".*\"/\"buildHash\": \"$BUILD_COMMIT_HASH\"/" mdm-frontend/src/assets/config.json | |
cat mdm-frontend/src/assets/config.json | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: 17 | |
- name: Cache maven artifacts | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-maven-artifacts | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} | |
- name: Install MDM Maven plugin | |
shell: bash | |
run: mvn -f maven-plugin/pom.xml install | |
- name: Install AWS CLI | |
run: pip install awscli | |
- name: Install jq for commandline json parsing | |
run: sudo apt-get -y install jq --allow-unauthenticated | |
- name: Set up node 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('mdm-frontend/package-lock.json') }} | |
- name: Extract branch name | |
shell: bash | |
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV | |
- name: Build with Maven and deploy with AWS CLI | |
run: ./deploy/build-and-deploy.sh unused ${{ env.BRANCH }} | |
env: | |
REPO_GITHUB_USERNAME: ${{ secrets.REPO_GITHUB_USERNAME }} | |
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Report Code Coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Deploy Javadoc to Github Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages # The branch the action should deploy to. | |
folder: target/site/apidocs # The folder the action should deploy. | |
- name: Report build status via Slack | |
uses: act10ns/slack@v2 | |
if: always() | |
with: | |
status: ${{ job.status }} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |