Update maven.yml #507
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
# This workflow will build a Java project with Maven | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI & CD with Maven | |
on: | |
push: | |
branches: [ master, develop ] | |
pull_request: | |
branches: [ master, develop ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Maven | |
uses: stCarolas/setup-maven@v4.5 | |
with: | |
maven-version: 3.9.0 | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Copy toolchain | |
run: | | |
mkdir -p ~/.m2/ | |
echo "<toolchains xmlns=\"http://maven.apache.org/TOOLCHAINS/1.1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd\"><toolchain><type>jdk</type><provides><id>JavaSE-17</id><version>17</version><vendor>eclipse</vendor></provides><configuration><jdkHome>/$JAVA_HOME</jdkHome></configuration></toolchain></toolchains>" > ~/.m2/toolchains.xml | |
- name: Build with Maven | |
run: | |
mvn -B clean package --file pom.xml | |
- name: Deploy with Maven | |
env: | |
BT_PAT: ${{ secrets.BT_TOKEN }} | |
run: | | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><settings xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd\" xmlns=\"http://maven.apache.org/SETTINGS/1.1.0\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><servers><server><configuration><httpHeaders><property><name>Authorization</name><value>Bearer $BT_PAT</value></property></httpHeaders></configuration><id>github</id></server></servers><profiles><profile><repositories><repository><id>central</id><url>https://repo1.maven.org/maven2</url></repository><repository><id>github</id><url>https://maven.pkg.github.com/enterpriseDomain/*</url><snapshots><enabled>true</enabled></snapshots></repository></repositories><id>github</id></profile></profiles><activeProfiles><activeProfile>github</activeProfile></activeProfiles></settings>" > ~/.m2/settings.xml | |
mvn clean deploy -s ~/.m2/settings.xml | |